To display all directories, one after the other, in alphabetical order, in wide format and pausing after each screen, make sure that the root directory is the current directory, and then type:
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 file names in each subdirectory in the tree.
To alter the preceding example so that dir displays the file names and extensions, but omits the directory names, type:
dir /s/w/o/p/a:-d
To print a directory listing, type:
ir > prn
When you specify prn, the directory list 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 file name. You can also type a path. For example, to direct dir output to the file Dir.doc in the Records directory, type:
dir > \records\dir.doc
If Dir.doc does not exist, dir creates it, unless the Records directory does not exist. In that case, the following message appears:
File creation error
To display a list of all the file names with the .txt extension in all directories on drive C, type:
dir c:\*.txt /w/o/s/p
Dir displays, in wide format, an alphabetized list of the matching file names in each directory and pauses each time the screen fills up, until you press a key to continue.