How do i get a list of folders and sub folders without the files?

前端 未结 6 1335
[愿得一人]
[愿得一人] 2020-12-04 07:26

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

When I run dir

相关标签:
6条回答
  • 2020-12-04 07:58

    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.

    0 讨论(0)
  • 2020-12-04 08:04

    dir /ad /b /s will give the required answer.

    0 讨论(0)
  • 2020-12-04 08:07

    I am using this from PowerShell:

    dir -directory -name -recurse > list_my_folders.txt
    
    0 讨论(0)
  • 2020-12-04 08:17

    Try this:

    dir /s /b /o:n /ad > f.txt
    
    0 讨论(0)
  • 2020-12-04 08:20
     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

    0 讨论(0)
  • 2020-12-04 08:20

    I don't have enough reputation to comment on any answer. In one of the comments, someone has asked how to ignore the hidden folders in the list. Below is how you can do this.

    dir /b /AD-H
    
    0 讨论(0)
提交回复
热议问题