Dir--Examples
Suppose you want dir to display one directory listing after another, until it has displayed the
listing for every directory on the disk in the current drive. Suppose also that
you want dir to alphabetize each directory listing, display it in wide format, and pause
after each screen.
To specify such a display, be sure the root directory is the current directory
and then type the following command:
dir /s/w/o/p
Dir lists the name of the root directory, the names of the subdirectories of the
root directory, and the names of the files in the root directory (including
extensions). Then dir lists the subdirectory names and filenames in each subdirectory in the
directory tree.
To alter the preceding example so that dir displays the filenames and extensions but omits the directory names, type the
following command:
dir /s/w/o/p/a:-d
To print a directory listing, type the redirection symbol and PRN after any
form of the dir command, as the following example shows:
dir > prn
When you specify PRN on the dir command line, the directory listing is sent to the printer attached to the
LPT1 port. If your printer is attached to a different port, you must replace PRN
with the name of the correct port.
You can also redirect output of the dir command to a file by replacing PRN with a filename. A path is also accepted
on the command line. For example, to direct dir output to the file DIR.DOC in the RECORDS directory, type the following
command:
dir > \records\dir.doc
If DIR.DOC does not exist, Windows NT creates it, unless the directory RECORDS
also does not exist. In that case, Windows NT displays the following message:
File creation error
To display a list of all the filenames with the .TXT extension in all
directories on drive C, type the following command:
dir c:\*.txt /w/o/s/p
Dir displays, in wide format, an alphabetized list of the matching filenames in
each directory and pauses each time the screen fills, until you press a key to
continue.
More Information About Dir
Dir--Notes
Dir