0

I have a folder with a list of folders. Without manually going through the list and typing the name of each folder, is there a way I can get a new line delimited list of the folders (or file names for that matter) in that directory?

2

2 Answers 2

1

If I am understanding your question correctly, it's pretty simple from the command line:

  1. Open a command prompt (Win+R, then enter "cmd" and hit enter) (alternatively, just search for "cmd" in windows search)
  2. Navigate to the folder in question (e.g. cd c:\My\Directory, you can copy this from your explorer window)
  3. Use the dir command and redirect the output to a file: dir > myfile.txt

That will give you a list of everything in the folder. See Here for MS KB Article

0
1

If you want a new list of all folders you can use the console. 'CD' into your folder and then use:

dir /AD /B /S /O:N > folderlist.txt

This displays a list of directories and subdirectories in a given root directory. The output file folderlist.txt will be in the parent directory

  • /AD lists only directories
  • /B suppresses unnecessary header information
  • /S searches for sub-directories too
  • Sorts the output alphabetically

Full help from cmd> dir /?

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
  /B          Uses bare format (no heading information or summary).
  /C          Display the thousand separator in file sizes.  This is the
              default.  Use /-C to disable display of separator.
  /D          Same as wide but files are list sorted by column.
  /L          Uses lowercase.
  /N          New long list format where filenames are on the far right.
  /O          List by files in sorted order.
  sortorder    N  By name (alphabetic)       S  By size (smallest first)
               E  By extension (alphabetic)  D  By date/time (oldest first)
               G  Group directories first    -  Prefix to reverse order
  /P          Pauses after each screenful of information.
  /Q          Display the owner of the file.
  /R          Display alternate data streams of the file.
  /S          Displays files in specified directory and all subdirectories.
  /T          Controls which time field displayed or used for sorting
  timefield   C  Creation
              A  Last Access
              W  Last Written
  /W          Uses wide list format.
  /X          This displays the short names generated for non-8dot3 file
              names.  The format is that of /N with the short name inserted
              before the long name. If no short name is present, blanks are
              displayed in its place.
  /4          Displays four-digit years

1
  • I appreciate the additional syntax for a recursive list. Didn't need that in this case but that might come in handy.
    – Shane
    Aug 28, 2015 at 15:39

Not the answer you're looking for? Browse other questions tagged .