Ink*_*key 77 directory cmd subdirectory
我试图将目录的文件夹和子文件夹列表打印到文件.
当我运行时dir /s/b/o:n > f.txt,我也得到了一个文件列表.我只需要文件夹和子文件夹.
任何人都知道这可以从命令行界面执行此操作吗?
End*_*oro 141
试试这个:
dir /s /b /o:n /ad > f.txt
Run Code Online (Sandbox Code Playgroud)
evi*_*uff 19
Displays a list of files and subdirectories in a directory.
DIR [ drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
[/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
[drive:][path][filename]
Specifies drive, directory, and/or files to list.
/A Displays files with specified attributes.
attributes D Directories R Read-only files
H Hidden files A Files ready for archiving
S System files I Not content indexed files
L Reparse Points - Prefix meaning not
Run Code Online (Sandbox Code Playgroud)
只需设置所需文件属性的类型,在您的情况下/ A:D(目录)
dir/s/b/o:不适用:D> f.txt
我在 PowerShell 中使用它:
dir -directory -name -recurse > list_my_folders.txt
Run Code Online (Sandbox Code Playgroud)
小智 5
我没有足够的声誉来评论任何答案。在其中一条评论中,有人询问如何忽略列表中的隐藏文件夹。以下是您如何做到这一点。
dir /b /AD-H
Run Code Online (Sandbox Code Playgroud)