help.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DIR--Notes
Examples  Syntax
────────────────────────────────────────────────────────────────────────────
 
                                 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.
 
                                      ♦