How do i get a list of folders and sub folders wit

2019-01-21 00:51发布

I am trying to print a list of the folders and sub folders of a directory to a file.

When I run dir /s/b/o:n > f.txt, I get a list of the files also. I only need the folders and sub folders.

Anyone know is this possible to do this from command line interface?

4条回答
Fickle 薄情
2楼-- · 2019-01-21 01:10

I used dir /s /b /o:n /a:d, and it worked perfectly, just make sure you let the file finish writing, or you'll have an incomplete list.

查看更多
地球回转人心会变
3楼-- · 2019-01-21 01:11
 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

just set type of desired file attribute, in your case /A:D (directory)

dir /s/b/o:n/A:D > f.txt

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-21 01:15

dir /ad /b /s will give the requried answer

查看更多
Luminary・发光体
5楼-- · 2019-01-21 01:35

Try this:

dir /s /b /o:n /ad > f.txt
查看更多
登录 后发表回答