List 如何在.cmd脚本中获取文件夹列表
我想获得某个目录中的文件夹列表 以下是我试图做到这一点的方式:List 如何在.cmd脚本中获取文件夹列表,list,cmd,dir,List,Cmd,Dir,我想获得某个目录中的文件夹列表 以下是我试图做到这一点的方式: for /d %%a in (*) do dir "c:\Users\cowman\FolderA" /a:d /o:n /b "%%a" >> get_dirs.txt 这给了我一个FolderA中所有文件夹的列表。但是,不幸的是,它多次列出文件夹。我只想把它们列一次。我怎样才能一次把它们列出来 dir "c:\Users\cowman\FolderA" /a:d /o:n /b > get_dirs.txt
for /d %%a in (*) do dir "c:\Users\cowman\FolderA" /a:d /o:n /b "%%a" >> get_dirs.txt
这给了我一个FolderA中所有文件夹的列表。但是,不幸的是,它多次列出文件夹。我只想把它们列一次。我怎样才能一次把它们列出来
dir "c:\Users\cowman\FolderA" /a:d /o:n /b > get_dirs.txt
使用
重新创建文件<代码>>>附加到任何现有文件
或者,如果需要目标子目录中的目录列表,请使用
dir "c:\Users\cowman\FolderA" /a:d /o:n /s /b > get_dirs.txt
如果不希望递归列表,请使用:
dir "c:\Users\cowman\FolderA" /b /ad > get_dirs.txt
检查,,…感谢回答的人。我发现这个问题是由于在需要创建新文件时,将命令的结果附加到现有文件中造成的。