Index | Syntax | Notes DIRCMD



DIR--Examples

Suppose you want to display all files and directories in a directory, including hidden or system files. To specify this display, type the following command: dir /a 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, MS-DOS creates it, unless the directory RECORDS also does not exist. In that case, MS-DOS 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.
-Top- | Syntax | Notes DIRCMD