Tree 命令提示符中树的输出

Tree 命令提示符中树的输出,tree,cmd,Tree,Cmd,我希望能够使用 tree /F /A > "desktop"\file.txt 命令仅输出文本文件。目前,它按原样输出每个文件扩展名 有人知道这样做的简单方法吗?树只接受几个命令行参数: 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 e

我希望能够使用

tree /F /A > "desktop"\file.txt
命令仅输出文本文件。目前,它按原样输出每个文件扩展名


有人知道这样做的简单方法吗?

树只接受几个命令行参数:

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.
指示的参数都不是文件掩码或筛选器

您可以使用带有适当开关的
dir
,并将输出重定向到文本文件。您将获得文件的完整路径名,但如果需要,您可以使用
for
循环在以后的处理中过滤掉它:

C:\>dir *.txt /s /b > filelist.txt

实际上,使用FINDSTR正则表达式获得所需的树输出并不难。:-)


注意:
tree
命令不会按名称对输出排序

相反,您可以使用以下方法:

dir /b /s /ad /on c:\ > c:\file.txt
结果看起来不太好,但是

更简单

您只需按如下方式导出结果:
树/a/f>“toto.rtf”


然后用Word打开文件并选择转换。

另一个简单选项:转到要列出的目录,键入CMD,这样您就已经在正确的位置了,然后:

树/a/f>“output.doc”


这将把它放入word文档中,更易于编辑和格式化。

注意-我在服务器上尝试树函数时,命令提示符被锁定。在.cmd文件中使用'dir'命令效果最好。不是很难吗?这是一些向导级的东西+1我希望了解您是如何获得此解决方案的,而且这应该是可接受的解决方案。这如何抑制不是
.txt
的文件?
dir /b /s /ad /on c:\ > c:\file.txt