Capturing List of Files into text file (using DOS)

Let's begin, Windows has no easy way to copy a list of files from My Computer or Windows Explorer and then put it into a text file, but DOS has that option. However, not many know this trick, so I'll share it with you.

Open command prompt, make sure it's you are in the correct folder, for example, if you want to copy cd contents, you can move there by typing "D:" in the prompt. Then, type "DIR /S > C:\list.txt"

let's examine it, DIR means you want to use the whole directory, /S means that you want to include all the subfolders (if you want only that folder, remove /S). FInally, C:\list.txt is the location of where to save the text file.

You can modify this to fit your needs, for example,

/B Uses bare format, no heading information nor summary. Just outputs a list of files and nothing else.


/L Uses lowercase only.


/O List by files in sorted order, with a colon followed by the ordering.

  • /O:N by name
  • /O:S by size (smallest goes first)
  • /O:E by extension (alphabetic order)
  • /O:D by date/time (oldest goes first)
  • /O:G Group (directories go first)
  • - Prefix (reverses order). For Instance, /O:-N would sort names in reverse alphabetical order.

If you want to group directories first, then sort by a second criterion, you can use /O more than once. For example, /O:S/O:G will group by size first, then sort by directory.

/P Pauses after each screen of info.

/W Uses wide list format. In other words, instead of a long single column of file names, you get multiple columns across the screen.

/4 Displays 4-digit years


You can use combinations, for example, DIR MYSTUFF/S/P/L/4 will list all subdirectories, pause the listing after each screen, list file names in lower case and with 4-digit years.

 

 

ITTIPS.NET - created and maintained by Albert Khaydatov.