DIR - Display directories
Purpose: Display information about files and subdirectories.
Format: DIR [/1 /2 /4 /A[[:][-]rhsda] /B /D /E /F /G /H /I"text" /J
/K /L /M /N /O[[:][-]adeginrsu] /P /R /S /T[:acw] /U /V /W
/Z] [file ...]
file : The file, directory, or list of files or directories
to display.
/1 (one column) /L(ower case)
/2 (two columns) /M (suppress footer)
/4 (four columns) /N(ew format)
/A(ttribute select) /O(rder)
/B(are) /P(ause)
/D(isable color coding) /R (disable wRap)
/E (use upper case) /S(ubdirectories)
/F(ull path) /T (aTtribute) or (Time)
/G (allocated size) /U (sUmmary information)
/H(ide dots) /V(ertical sort)
/I (match descriptions) /W(ide)
/J(ustify names) /Z (use FAT format)
/K (suppress header)
See also: ATTRIB, DESCRIBE, SELECT, and SETDOS.
File Selection
Supports extended wildcards, ranges, multiple file names, and include
lists.
Usage
DIR can be used to display information about files from one or more of
your disk directories, in a wide range of formats. Depending on the
options chosen, you can display the file name, attributes, and size; the
time and date of the last change to the file; the file description; and
the file's compression ratio. You can also display information in 1, 2,
4, 5, or more columns, sort the files several different ways, use color
to distinguish file types, and pause after each full screen.
The various DIR displays are controlled through options or switches. The
best way to learn how to use the many options available with the DIR
command is to experiment. You will soon know which options you want to
use regularly. You can select those options permanently by using the
ALIAS command.
For example, to display all the files in the current directory, in 2
columns, sorted vertically (down one column then down the next), and with
a pause at the end of each page:
[c:\] dir /2/p/v
To set up this format as the default, using an alias:
[c:\] alias dir=*dir /2/p/v
When you use DIR on an HPFS drive, you must quote any file names which
contain whitespace or special characters. See File Names for additional
details.
The following sections group DIR's features together in several
categories. Many of the sections move from a general discussion to more
technical material. If you find some of the information in a category
too detailed for your needs, feel free to skip to the beginning of the
next section. The sections are:
Selecting Files
Default DIR Output Format
Switching Formats
Multiple Column Displays
Color-Coded Directories
Redirected Output
Other Notes
Options
Selecting Files
DIR can display information about a single file or about several, dozens,
hundreds, or thousands of files at once. To display information about a
single file, just add the name of the file to the DIR command line:
[c:\] dir january.wks
The simplest way to view information about several files at once is to
use wildcards. DIR can work with traditional wildcard characters (* and
?) and the extended wildcards. For example to display all of the .WKS
files in the current directory:
[c:\] dir *.wks
To display all .TXT files whose names begin with A, B, or C:
[c:\] dir [abc]*.txt
If you don't specify a filename, DIR defaults to *.* on traditional FAT
drives, and * on HPFS drives. This default displays all non-hidden files
and subdirectories in the current directory.
If you link two or more filenames together with spaces, DIR will display
all of the files that match the first name and then all of the files that
match the second name. You may use a different drive and path for each
filename. This example lists all of the .WKS and then all of the .WK1
files in the current directory:
[c:\] dir *.wks *.wk1
If you use an include list to link multiple filenames, DIR will display
the matching filenames in a single listing. Only the first filename in
an include list can have a path; the other files must be in the same
path. This example displays the same files as the previous example, but
the .WKS and .WK1 files are intermixed:
[c:\] dir *.wks;*.wk1
You can include files in the current or named directory plus all of its
subdirectories by using the /S option. This example displays all of the
.WKS and .WK1 files in the D:\DATA directory and each of its
subdirectories:
[c:\] dir /s d:\data\*.wks;*.wk1
You can also select files by their attributes by using the /A option.
For example, this command displays the names of all of the
subdirectories of the current directory:
[c:\] dir /a:d
Finally, with the /I option, DIR can select files to display based on
their descriptions (see the DESCRIBE command for more information on file
descriptions). DIR will display a file if its description matches the
text after the /I switch. The search is not case sensitive. You can use
wildcards and extended wildcards as part of the text. For example, to
display any file described as a "Test File" you can use this command:
[c:\] dir /i"test file"
If you want to display files that include the words "test file" anywhere
in their descriptions, use extended wildcards like this:
[c:\] dir /i"*test file*"
To display only those files which do not have descriptions, use:
[c:\] dir /I"[]"
In addition, you can use ranges to select or exclude specific sets of
files. For example, to display all files modified in the last week, all
files except those with a .BAK extension, and all files over 500 KB in
size:
[c:\] dir /[d-7]
[c:\] dir /[!*.bak]
[c:\] dir /[s500K]
You can, of course, mix any of these file selection techniques in
whatever ways suit your needs.
Default DIR Output Format
DIR's output varies based on the type of volume or drive on which the
files are stored. On an HPFS volume, the default DIR format contains 4
columns: the date of the last file modification or write, the time of
last write, the file size in bytes, and the file name. The name is
displayed as it is stored on the disk, in upper, lower, or mixed case.
DIR will wrap filenames from one line to the next if they are too long
to fit the width of the display. The standard output format is:
Volume in drive C is C - BOOTUP Serial ...
Directory of C:\CMD.EXE301\*.*
10-24-96 12:17 <DIR> .
10-24-96 12:17 <DIR> ..
10-28-96 7:57 967 CMD.EXE 3.txt
10-21-96 18:08 212,854 CMD.EXE.EXE
11-02-96 10:08 45 CMD.INI
(See Switching Formats below for information on changing the standard
long filename format to allow room for file descriptions.)
On FAT volumes which do not support long file names, the default DIR
format contains 5 columns: the file name, the file size in bytes, the
date of the last write, the time of the last write, and the file's
description. File names are listed in lower-case; directory names in
upper case:
Volume in drive C is C - BOOTUP Serial ...
Directory of C:\CMD.EXE30\*.*
. <DIR> 10-24-96 12:17
.. <DIR> 10-24-96 12:17
TEST <DIR> 11-01-96 16:21
CMD.EXE3.txt 967 10-28-96 7:57
CMD.EXE.exe 212854 10-21-96 18:08 CMD.EXE exe ...
CMD.INI 45 11-02-96 10:08 CMD.EXE conf ...
DIR's output is normally sorted by name, with directories listed first.
You can change the sort order with the /O option. For example, these
two commands sort the output by date -- the first command lists the
oldest file first; the second command lists the oldest file last:
[c:\] dir /o:d
[c:\] dir /o:-d
When displaying file descriptions, DIR wraps long lines to fit on the
screen. DIR displays a maximum of 40 characters of text in each line of
a description, unless your screen width allows a wider display. If you
disable description wrapping with the /R option, the description is
truncated at the right edge of the screen, and a right arrow [>] is added
at the end of the line to alert you to the existence of additional
description text.
Regardless of the volume type, DIR's default output is sorted. It
displays directory names first, with "<DIR>" inserted instead of a file
size, and then filenames. DIR assumes that sequences of digits should be
sorted numerically (for example, the file DRAW2 is listed before DRAW03
because 2 is numerically smaller than 03), rather than strictly
alphabetically (where DRAW2 would come second because "2" is after "0" in
alphanumeric order). You can change the sort order with the /O option.
When DIR displays file names in a multi-column format, it sorts file
names horizontally unless you use the /V option to display vertically
sorted output.
DIR's display can be modified in many ways to meet different needs. Most
of the following sections describes the various ways you can change DIR's
output format.
Switching Formats
On HPFS volumes, you can force DIR to use a FAT-like format (file name
first, followed by file information) with the /Z option. If necessary,
DIR /Z truncates long file names on HPFS drives, and adds a right arrow
[>] to show that the name contains additional characters.
The standard HPFS output format does not provide enough space to show
descriptions along with file names. Therefore, if you wish to view file
descriptions as part of the DIR listing on an HPFS volume, you must use
the /Z option.
If you use the /B option, DIR displays just file names and omits the file
size, time stamp, and description for each file, for example:
[c:\] dir i* /b
IBMCOM
IBMI18N
IBMINST
IBMVESA
IBMLVL.INI
.....
There are several ways to modify the display produced by /B. The /F
option is similar to /B, but displays the full path and name of each
file, instead of just its name. To view the same information for a
directory and its subdirectories use /B /S or /F /S.
Multiple Column Displays
DIR has three options, /2, /4, and /W, that create multi-column displays.
On HPFS drives, all 3 of these options force the use of truncated names.
The /2 option creates a 2-column display. On HPFS drives, only the name
of each file is displayed, with directory names placed in square brackets
to distinguish them from file names. On FAT drives, support long
filenames, or when /Z or /X is used (see below), the display includes the
name, file size, and time stamp for each file.
The /4 option is similar to /2, but displays directory information in 4
columns. On drives which do not support long filenames, or when /Z
or /X is used (see below), the display shows the file name and the file
size in kilobytes (KB) or megabytes (MB), with "<D>" in the size column
for directories.
The /W option displays directory information in 5 or more columns,
depending on your screen width. Each entry in a DIR /W display contains
either the name of a file or the name of a directory. Directory names
are placed in square brackets to distinguish them from file names.
If you use one of these options on an HPFS drive and do not select an
alternate display format with /Z or /X, the actual number of columns will
be based on the longest name to be displayed and your screen width, and
may be less than the number you requested (for example, you might see
only three columns even though you used /4). If the longest name is too
long to fit in on a single line the display will be reduced to one
column, and each name will be wrapped, with "extra" blank lines added so
that each name takes the same number of lines.
Color-Coded Directories
The DIR command can display each file name and the associated file
information in a different color, depending on the file's extension.
To choose the display colors, you must either use the SET command to
create an environment variable called COLORDIR, or use the Commands page
of the OPTION dialogs or a text editor to set the ColorDir directive in
your .INI file. If you do not use the COLORDIR variable or the ColorDir
directive, DIR will use the default screen colors for all files.
If you use both the COLORDIR variable and the ColorDir directive, the
environment variable will override the settings in your .INI file. You
may find it useful to use the COLORDIR variable for experimenting, then
to set permanent directory colors with the ColorDir directive.
The format for both the COLORDIR environment variable and the ColorDir
directive in the .INI file is:
ext ... :ColorName; ...
where "ext" is a file extension (which may include wildcards) or one of
the following file types:
DIRS Directories
RDONLY Read-only files
HIDDEN Hidden files
SYSTEM System files
ARCHIVE Files modified since the last backup
and "ColorName" is any valid color name (see Colors and Color Names).
Unlike most color specifications, the background portion of the color
name may be omitted for directory colors. If you don't specify a
background color, DIR will use the current screen background color.
For example, to display the .COM and .EXE files in red on the current
background, the .C and .ASM files in bright cyan on the current
background, and the read-only files in blinking green on white (this
should be entered on one line):
[c:\] set colordir=com exe:red; c asm:bright cyan;
rdonly:blink green on white
Extended wildcards can be used in directory color specifications. For
example, to display .BAK, .BAX, and .BAC files in red:
[c:\] set colordir=BA[KXC]:red
Redirected Output
The output of the DIR command, like that of most other internal commands,
can be redirected to a file, printer, serial port, or other device.
However, you may need to take certain DIR command options into account
when you redirect DIR's output.
DIR wraps both long file names and file descriptions at the width of your
display. Its redirected output will also wrap at the screen width. Use
the /R option if you wish to disable wrapping of long descriptions.
If you redirect a color-coded directory to a file, DIR will remove the
color data as it sends the directory information to a file. It will
usually do the same if you redirect output to a character device such as
a printer or serial port. However, it is not always possible for DIR to
tell whether or not a device is a character device. If you notice that
non-colored lines are being sent to the output device and colored lines
are appearing on your screen, you can use the /D option to temporarily
disable color-coding when you redirect DIR's output.
To redirect DIR output to the clipboard, use CLIP: as the output device
name, for example:
[c:\] dir *.exe > clip:
Other Notes
If you have selected a specific country code for your system, DIR will
display the date in the format for that country. The default date format
is U.S. (mm-dd-yy). The separator character in the file time will also
be affected by the country code. Thousands and decimal separators in
numeric displays are affected by the country code, and by the
ThousandsChar and DecimalChar settings selected on the Options 1 page of
the OPTION dialogs or in the .INI file.
Options
Options on the command line apply only to the filenames which follow the
option, and options at the end of the line apply to the preceding
filename only. This allows you to specify different options for
different groups of files, yet retains compatibility with the traditional
DIR command when a single filename is specified.
/1: Single column display -- display the filename, size, date, and
time; also displays the description on drives which do not
support long filenames. This is the default. If /T is used
the attributes are displayed instead of the description. This
option is most useful if you wish to override a default /2,
/4, or /W setting stored in an alias.
/2: Two column display -- display just the name (on HPFS drives),
or display the filename, size, date, and time on other drives.
See Multiple Column Displays above for more details.
/4: Four column display -- display just the name (on HPFS drives);
or display the filename and size, in K (kilobytes) or M
(megabytes), with files between 1 and 9.9 megabytes in size
displayed in tenths (i.e. "2.4M"). See Multiple Column
Displays above for more details.
/A: (Attribute select) Select only those files that have the
specified attribute(s) set. Preceding the attribute character
with a hyphen [-] will select files that do not have that
attribute set. The colon [:] after /A is optional. The
attributes are:
R Read-only
H Hidden
S System
D Subdirectory
A Archive
If no attributes are listed at all (e.g., DIR /A ...), DIR
will display all files and subdirectories including hidden and
system files. If attributes are combined, all the specified
attributes must match for a file to be included in the
listing. For example, /A:RHS will display only those files
with all three attributes set.
/B: (Bare) Suppress the header and summary lines, and display
file or subdirectory names only, in a single column. This
option is most useful when you want to redirect a list of
names to a file or another program. If you use /B with /S,
DIR will show the full path of each file (the same display as
/F) instead of simply its name and extension.
/D: (Disable color coding) Temporarily disable directory color
coding. May be required when color-coded directories are used
and DIR output is redirected to a character device like the
printer (e.g., PRN or LPT1) or serial port (e.g., COM1 or
COM2). /D is not required when DIR output is redirected to a
file.
/E: Display filenames in the traditional upper case; also see
SETDOS /U and the UpperCase directive in CMD.INI.
/F: (Full path) Display each filename with its drive letter and
path in a single column, without other information. If you
use /F with /X on a volume which supports long filenames, the
"short" version of the entire path is displayed.
/G: Display the allocated disk space instead of the actual size of
each file.
/H: (Hide dots) Suppress the display of the "." and ".."
directories.
/I: Display filenames by matching text in their descriptions. The
text can include wildcards and extended wildcards. The search
text must be enclosed in quotation marks. You can select all
filenames that have a description with /I"[?]*", or all
filenames that do not have a description with /I"[]".
The /I option may be used to select files even if descriptions
are not displayed (for example, if /2 is used). However, /I
will be ignored if /O:c is used.
/J: (Justify names) Justify (align) filename extensions and
display them in the traditional format.
/K: Suppress the header (disk and directory name) display.
/L: (Lower case) Display file and directory names in lower case;
also see SETDOS /U and the UpperCase directive in CMD.INI.
/M: Suppress the footer (file and byte count totals) display.
/N: Use the HPFS display format, even if the files are stored on a
volume which does not support long names. See also /Z.
/O: (Order) Set the sorting order. You may use any combination of
the following sorting options; if multiple options are used,
the listing will be sorted with the first sort option as the
primary key, the next as the secondary key, and so on:
- Reverse the sort order for the next option.
a Sort in ASCII order, not numerically, when there are
digits in the name.
d Sort by date and time (oldest first); for HPFS drives,
also see /T.
e Sort by extension.
g Group subdirectories first, then files.
i Sort by file description (ignored if /O:c is used).
n Sort by filename (this is the default).
r Reverse the sort order for all options.
s Sort by size.
u Unsorted.
/P: (Pause) Wait for a key to be pressed after each screen page
before continuing the display. Your options at the prompt are
explained in detail under Page and File Prompts.
/R (disable wRap) Forces long descriptions to be displayed on a
single line, rather than wrapped onto two or more lines. Use
/R when output is redirected to a character device, such as a
serial port or the printer; or when you want descriptions
truncated, rather than wrapped, in the on-screen display.
/S: (Subdirectories) Display file information from the current
directory and all of its subdirectories. DIR will only
display headers and summaries for those directories which
contain files that match the filename(s), ranges, and
attributes that you specify on the command line.
/T (aTtribute display) Display the filenames, attributes, and
descriptions. The descriptions will be wrapped onto the next
line, if necessary, unless you also use the /R (truncate)
option. If you use both /T and /R, descriptions are truncated
after 34 characters on an 80-column display. The attributes
are displayed in the format RHSA, with the following meanings:
R Read-only
H Hidden
D Directory
S System
A Archive
On HPFS drives, if you wish to add another option after /T,
you must start the next option with a forward slash. If you
don't, CMD.EXE will interpret the /T as the time display
switch and the following character as a valid or invalid time
selector. For example:
[c:\] dir /tz incorrect, will display error
[c:\] dir /t/z correct
/T:acw (Time display) Specify which of the date and time fields on
an HPFS drive should be displayed and used for sorting:
a Last access date and time.
c Creation date and time.
w Last write date and time (default).
/U (sUmmary information) Only display the number of files, the
total file size, and the total amount of disk space used.
Information on individual files is not displayed.
/V: (Vertical sort) Display the filenames sorted vertically
rather than horizontally (use with the /2, /4 or /W options).
/W: (Wide) Display filenames only, horizontally across the
screen. On FAT drives, /W displays as many columns as it can
fit into the command processor window, using 16 characters in
each column. Otherwise (i.e., when long filenames are
displayed) the number of columns depends on the width of the
longest name in the listing. See Multiple Column Displays
above for more details.
/Z: Display an HPFS directory in the traditional FAT format, with
the filename at the left and the description at the right. Long
names will be truncated to 12 characters unless /X is also
used; if the name is longer than 12 characters, it will be
followed by a right arrow [>] to show that one or more
characters have been truncated.
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs