Windows 7 / Getting Started

Listing Files with the Dir Command

The dir command is one of the most helpful command-line programs. Although it's often more efficient to use Explorer to view folder contents, dir has a few tricks up its sleeve that make it worth knowing about.

Without any command-line arguments, dir prints a listing of files and directories (folders) in the current directory. Here's a sample listing:

Volume in drive C has no label.
Volume Serial Number is 7AC1-7AC5

Directory of C:\Users\bknittel\Documents

05/27/2010 06:27 PM 	<DIR> .
05/27/2010 06:27 PM 	<DIR> ..
04/30/2009 06:23 PM 	<DIR> Fax
05/21/2009 04:15 PM 	<DIR> Remote Assistance Logs
05/26/2009 06:28 PM 	<DIR> Book Files
04/30/2009 06:23 PM 	<DIR> Scanned Documents
05/27/2009 05:02 PM   28,672 book outline.xls
	      1 File(s) 28,672 bytes
	      6 Dir(s) 1,132,052,480 bytes free

(If you've only ever used Macintosh- or Windows-based computers, you might find it hard to believe that not too many years ago, this was the only way to view and locate files.)

So what are . and ..? These two odd entries represent the current directory and its parent directory.They serve no real purpose today; they're the software equivalent to your appendix, a remnant of MS-DOS's distant Unix ancestry, and you can ignore them.

The rest of the listing shows the names of the directory's files and subdirectories as well as their sizes and last-modified dates.The listing ends with a summary of file counts and sizes.

In Reference List below, I showed all the command-line options you can use with dir. In this section, I go over a few of the ones that are particularly useful.

[Previous] [Contents] [Next]