DIR Power
When reading a directory on my PC, the file listing sometimes continues on for more than a full screen and it becomes impossible to read all the file-names before they are out of sight. Is it possible to stop this scrolling?
Also, on a keyboard that doesn't have a PrtSc key to print the screen, is it possible to get a printout of a directory listing?
Peter Richie
There are three ways to stop your directory listing from scrolling. The first is to press CONTROL-S to stop scrolling and to press any key to resume scrolling.
A second method is to append the switch /P to the DIR command like this
DIR/P
This pauses the directory listing between screenfuls of data.
The third option is to use the DOS filter MORE in a command line like the following:
DIR I MORE
This command will give essentially the same results as DIR /P discussed above.
While on the subject of directories and filters, there's another very useful DOS filter called SORT. With it, you can sort a directory (or any other file) on any field you wish. To create a sorted directory that will pause its display after each screen, use the following command:
DIR | SORT | MORE
Please note that you can't use the /P option to pause the directory when using the SORT filter. Also, when using filters, DOS creates a temporary file on your disk. There must be enough room on the current disk for the temporary file, and the disk cannot be write-protected.
The SORT filter can work wonders with directories. Since DOS is very rigid about the directory's format, you can tell SORT to begin sorting in certain columns and produce a directory sorted just the way you want. To sort a directory and specify a column in which to begin sorting, use a command of the form
DIR | SORT / + n
where n is the column number on which you want the sort to begin. Here are the important column numbers for the standard DOS directory:
1 | filename |
10 | file extension |
24 | date |
34 | time |
39 | meridian (a.m. or p.m.) |
If you want to view a directory sorted by file extension, for example, and also want the listing to pause after each screen, you would give the following command:
DIR | SORT / + 10 | MORE
It's easy to obtain a printout of your directory without using a PrtSc key because of a DOS mechanism called piping. Piping allows you to redirect the output of a program—like a directory listing—to any file or device you wish. To send the output of the above directory command to the printer, all you need to do is append > PRN to the command. The > tells DOS to redirect output (you can redirect input with <) and PRN tells it to send the output to the printer.
So, the entire command would look like this:
DIR | SORT / + 10 > PRN
Notice we didn't use the MORE filter. When sending output to a diskfile or printer, pauses after each screen are unnecessary.
With DOS's filters and redirection, the simple DIR command becomes a powerful tool.