Capturing File Lists

Steven Dutch, Natural and Applied Sciences,University of Wisconsin - Green Bay
First-time Visitors: Please visitSite Map and Disclaimer. Use "Back" to return here.

Believe it or not, Windows has no easy way to copy a list of files from My Computer or Windows Explorer and put it into a document. The most common method I've seen recommended is to do a screen capture and paste the resulting image. But of course you can't sort or edit the result.

This is one thing that is still better done in DOS (or command) mode than in Windows. So access Command Mode to begin.

DOS For the Chronologically Challenged

Okay you young punks, gather round while I tell you about the good old days of DOS, back when Hannibal was crossing the Alps and we had to walk miles through the snow to class and it was uphill both ways and computer speeds were measured in kilohertz. (They really were. I thought I was a serious computer stud in the late '70's when the Computer Center upgraded my mainframe account from 40 to 80 kilobytes. Computer heroism was mostly measured by your ability to endure pain.)

When you open Command Mode, you'll get a black screen with something like M:\> followed by a flashing underscore cursor. There are no menus. The mouse doesn't work here. You type the commands in. See the thing with letters in front of the computer? You have to poke the letters with your fingers. Start by typing HELP. You'll get a list of all the DOS commands and a quick description of each. For more detailed information, type HELP followed by a command. You will get a help page followed by the information on that command. The message --MORE-- at the bottom of the screen means - don't get ahead of me - there's more. Press Enter to see the next screen.

The two commands you need to know are CD (change directory) and DIR (directory). To change from one drive to another, just type the drive followed by a colon. C: will change you to the C: drive. You have to change drives this way.

DIR gives you a listing of the current directory, but if the directory is big, it will flash past. To slow down, enter DIR/p. The /p is called a switch - there are a bunch of them - and it pauses the listing after each screenful.

To get a listing of a desired subdirectory, you need to enter CD followed by the directory name. So to get to directory GEOPHOTO on my D: drive, I type D: then CD GEOPHOTO. Note: command mode is case-insensitive. To get to deeper directories, I use DIR/p, followed by CD to the desired directory, and so on.

If you know the entire path name, you can type it in all at once. For example, I can get from D: to D:\GEOPHOTO\WEST99\UTAH by successive DIR's and CD's, or I can type it in directly as CD GEOPHOTO\WEST99\UTAH. However, you can't go from, say, your M: drive to D:\GEOPHOTO\WEST99\UTAH  just by entering the path name. You have to change drives first, then use CD to navigate the drive. By the way, it used to matter a lot whether you used the forward slash or backslash, but Command Mode doesn't seem to care. If one doesn't work, try the other.

To drop back one level, you can type in CD.. (CD followed by two periods).

Now that you're in the desired directory, the command DIR will give you a listing of all the files. So what? Windows can do this, with no typing at all. Yes, but from Command Mode you can send the list to a text file. Believe it or not, Windows' recipe for getting a file list is do a screen capture, then copy it into your document as a picture.

Here's how - and you can't find this on the help screen. DOS allows you to redirect screen output using the > symbol. DIR MYFILES > PRN sends the output to your printer. DIR MYFILES > LIST.TXT sends it to a text file called LIST.TXT. If you want to verify that you indeed did get the file you wanted, the TYPE command displays a text file. Type in TYPE LIST.TXT to view the file. LIST.TXT, of course, will be in the directory you're listing unless you type in a longer path name.

This will work with any Command Mode output, so if you want a copy of the help page for DIR, enter HELP DIR > HELPDIRFILE.TXT. By the way, although Command Mode preserves most DOS capabilities, it's not exactly the same. One thing you can do in Command Mode that you couldn't do in old-time DOS is have file names longer than 8 characters.

Some Refinements

If you just proceed as above, you'll get a series of columns: the date, the time, whether or not it's a directory, the size of the file, and the name. You may or may not want all this, and it can be a pain to remove extraneous stuff from a long list.

Here's where the switches come in, and you can have more than one. These are the switches you'd be most likely to need.

/B Uses bare format (no heading information or summary). Just gives a list of files with nothing else.

/L Uses lowercase.

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

If you want to group directories first, then sort by some other criterion, you can use /O more than once. /O:G/O:S will group directories first, then sort by size.

/P Pauses after each screenful of information.

/S Displays files in specified directory and all subdirectories. A really useful item if you want to list a large number of files at once.

/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 four-digit years

DIR MYSTUFF/P/S/L/4 will pause the listing after each screenful, list all subdirectories, list file names in lower case and with four-digit years.


A fast way to clean up a file created this way is to bring it up in Excel or some other spreadsheet. Bring it in as a fixed column width file, set each column as desired, then use the spreadsheet to sort the data, delete columns, add text, and so on.

Return to Computer Tips Index
Return to Professor Dutch's Home Page

Created 18 January 2002, Last Update 11 May 2010

Not an official UW Green Bay site