如何在不列出当前目录的情况下批量创建文件夹树?

时间:2019-01-03 22:48:09

标签: batch-file

我正在尝试使用tree命令列出文件系统,但它会添加其他信息,例如当前目录以及正在列出的目录。

我尝试查看树的属性,但似乎找不到任何有效的方法。

rem Asks for user input
set /p COMMAND=What would you like to do? : 
rem Locates the command specified by the user
goto %COMMAND%

:settings
echo.
rem Clarifies that the action has been completed
echo Successfully opened settings panel
echo.
rem Shows a graphical tree of the specified file structure
tree "%CD%\settings\"
pause

我只期望:

├───accounts
├───apps
├───devices
├───language
├───network
├───personalization
├───privacy
├───security
├───system
├───time
└───update

但是我得到了:

Folder PATH listing
Volume serial number is 0000C2A7 06D5:17B1
C:\USERS\NOAH HERRON\DESKTOP\SYSTEM MANAGEMENT\SETTINGS
├───accounts
├───apps
├───devices
├───language
├───network
├───personalization
├───privacy
├───security
├───system
├───time
└───update

1 个答案:

答案 0 :(得分:1)

该标头内置于可执行文件tree.com
中 (是的,尽管它是64位程序,但它被命名为.com

使用for / f解析输出并跳过3行:

for /f "skip=3 delims=" %%A in ('tree "%CD%\settings\"') do Echo:%%A

或仅将管道树输出到|more +3

tree "%CD%\settings\" | more +3