| DIR |
|
| Displays a list of the files and subdirectories that are in the directory |
| you specify. |
|
| When you use DIR without parameters or switches, it displays the disk's |
| volume label and serial number; one directory or filename per line, |
| including the filename extension, the file size in bytes, and the date and |
| time the file was last modified; and the total number of files listed, their |
| cumulative size, and the free space (in bytes) remaining on the disk. |
|
| Syntax |
|
| DIR [drive:][path][filename] [/P] [/W] |
| [/A[[:]attributes]][/O[[:]sortorder]] [/S] [/B] [/L] [/C] |
|
| Parameters |
|
| [drive:][path] |
| Specifies the drive and directory for which you want to see a listing. |
|
| [filename] |
| Specifies a particular file or group of files for which you want to see |
| a listing. |
|
| Switches |
|
| /P |
| Displays one screen of the listing at a time. To see the next screen, |
| press any key. |
|
| /W |
| Displays the listing in wide format, with as many as five filenames or |
| directory names on each line. |
|
| /A[[:] attributes] |
| Displays only the names of those directories and files with the |
| attributes you specify. If you omit this switch, DIR displays the names |
| of all files except hidden and system files. If you use this switch |
| without specifying attributes, DIR displays the names of all files, |
| including hidden and system files. The following list describes each of |
| the values you can use for attributes. The colon (:) is optional. Use |
| any combination of these values, and do not separate the values with |
| spaces. |
|
| H |
| Hidden files |
|
| -H |
| Files that are not hidden |
|
| S |
| System files |
|
| -S |
| Files other than system files |
|
| D |
| Directories |
|
| -D |
| Files only (not directories) |
|
| A |
| Files ready for archiving (backup) |
|
| -A |
| Files that have not changed since the last backup |
|
| R |
| Read-only files |
|
| -R |
| Files that are not read-only |
|
| /O[[:] sortorder] |
| Controls the order in which DIR sorts and displays directory names and |
| filenames. If you omit this switch, DIR displays the names in the order |
| in which they occur in the directory. If you use this switch without |
| specifying sortorder, DIR displays the names of the directories, sorted |
| in alphabetic order, and then displays the names of files, sorted in |
| alphabetic order. The colon (:) is optional. The following list |
| describes each of the values you can use for sortorder. Use any |
| combination of the values, and do not separate these values with |
| spaces. |
|
| N |
| In alphabetic order by name |
|
| -N |
| In reverse alphabetic order by name (Z through A) |
|
| E |
| In alphabetic order by extension |
|
| -E |
| In reverse alphabetic order by extension (Z through A) |
|
| D |
| By date and time, earliest first |
|
| -D |
| By date and time, latest first |
|
| S |
| By size, smallest first |
|
| -S |
| By size, largest first |
|
| G |
| With directories grouped before files |
|
| -G |
| With directories grouped after files |
|
| C |
| By compression ratio, lowest first. |
|
| -C |
| By compression ratio, highest first. |
|
| /S |
| Lists every occurrence, in the specified directory and all |
| subdirectories, of the specified filename. |
|
| /B |
| Lists each directory name or filename, one per line (including the |
| filename extension). This switch displays no heading information and no |
| summary. The /B switch overrides the /W switch. |
|
| /L |
| Displays unsorted directory names and filenames in lowercase. This |
| switch does not convert extended characters to lowercase. |
|
| /C[H] |
| Displays the compression ratio of files compressed using Doublespace, |
| based on an 8K cluster size. The optional H switch displays the |
| compression ratio of files compressed using Doublespace, based on the |
| cluster size of the host drive. The /C[H] switch is ignored when used |
| with the /W or /B switch. |
|
| Related Commands |
|
| For information about displaying the directory structure of a path or disk, |
| see the TREE command. |
|
| For information about compressing disks, see the DBLSPACE command. |
|
|
| DIR--Notes |
|
| Using wildcards with DIR |
|
| You can use wildcards (* and ?) to display a listing of a subset of files |
| and subdirectories. For an example illustrating the use of a wildcard, see |
| the "Examples" screen. |
|
| Specifying file display attributes |
|
| If you specify the /A switch with more than one value in attributes, DIR |
| displays the names of only those files with all the specified attributes. |
| For example, if you specify the /A switch with the R and -H values for |
| attributes by using either /A:R-H or /AR-H, DIR displays only the names of |
| read-only files that are not hidden. |
|
| Specifying filename sorting |
|
| If you specify more than one sortorder value, DIR sorts the filenames by the |
| first criterion first, then by the second criterion, and so on. For example, |
| if you specify the /O switch with the E and -S values for sortorder by using |
| either /O:E-S or /OE-S, DIR sorts the names of directories and files by |
| extension, with the largest first, and displays the final result. The |
| alphabetic sorting by extension causes filenames with no extensions to |
| appear first, then directory names, then filenames with extensions. |
|
| Setting date and time formats |
|
| The date and time formats used by DIR depend on the country setting you use |
| in your CONFIG.SYS file. If you don't use the COUNTRY command, the formats |
| are those for the United States. |
|
| Using redirection symbols and pipes |
|
| When you use a redirection symbol ( ) to send DIR output to a file or a pipe |
| (|) to send DIR output to another command, use the /A:-D and /B switches to |
| list only the filenames. You can use the filename parameter with the /B and |
| /S switches to specify that DIR is to search the current directory and its |
| subdirectories for all filenames that match filename. DIR lists only the |
| drive letter, directory name, filename, and filename extension, one path per |
| line, for each filename it finds. |
|
| Before using a pipe for redirection, you should set the TEMP environment |
| variable in your AUTOEXEC.BAT file. Otherwise, the temporary file will |
| appear in the directory listing. |
|
| Presetting DIR parameters and switches |
|
| You can preset DIR parameters and switches by including the SET command with |
| the DIRCMD environment variable in your AUTOEXEC.BAT file. You can use any |
| valid combination of DIR parameters and switches with the SET DIRCMD |
| command, including the location and name of a file. |
|
| For example, to use the DIRCMD environment variable to set the wide display |
| format (/W) as the default format, include the following command in your |
| AUTOEXEC.BAT file: |
|
| set dircmd=/w |
|
| For a single use of the DIR command, you can override a switch set by using |
| the DIRCMD environment variable. To do so, you use the same switch on the |
| DIR command line, but you must also precede the switch letter with a minus |
| sign, as the following example shows: |
|
| dir /-w |
|
| You can change the DIRCMD default settings by typing the SET command at the |
| command prompt with a new parameter or switch after the equal sign (=). The |
| new default settings are effective for all subsequent DIR commands until you |
| use SET DIRCMD again on the command line or until you restart MS-DOS. |
|
| To clear all default settings, type the following command: |
|
| set dircmd= |
|
| You can view the current settings of the DIRCMD environment variable by |
| typing the following command: |
|
| set |
|
| MS-DOS displays a list of environment variables and their settings. For more |
| information about setting environment variables, see the SET command. |
|
|
| 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. |
|
|