July 14, 2014

Displays a list of files and sub directories in a directory in CMD Prompt.

 DIR [ drive:][path][file-name] [/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.
           D  Directories                R  Read-only files
           H  Hidden files               A  Files ready for archiving
           S  System files               I  Not content indexed files
           L  Re parse Points        -  Prefix meaning not

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

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

Source: Link

No comments:

Post a Comment