我希望能够使用
tree /F /A > "desktop"\file.txt
Run Code Online (Sandbox Code Playgroud)
命令只输出文本文件.目前,它输出每个文件扩展名.
有谁知道一个简单的方法来做到这一点?
Ken*_*ite 42
Tree 只接受几个命令行参数:
c:\>Tree /?
Graphically displays the folder structure of a drive or path.
TREE [drive:][path] [/F] [/A]
/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.
Run Code Online (Sandbox Code Playgroud)
所指示的参数都不是文件掩码或过滤器.
您可以使用dir正确的开关,并将输出重定向到文本文件.您将获得文件的完整路径名,但如果需要使用for循环,您可以在以后的处理中对其进行过滤:
C:\>dir *.txt /s /b > filelist.txt
Run Code Online (Sandbox Code Playgroud)
dbe*_*ham 11
使用FINDSTR正则表达式获得所需的TREE输出实际上并不困难.:-)
tree /f /a | findstr /ri /c:"^[^| ]" /c:"^[| ]*[+\\]" /c:"\.txt$"
Run Code Online (Sandbox Code Playgroud)