Dir
Displays a list of a directory's files and subdirectories.
dir [drive:][path][filename] [; ...] [/p] [/w] [/d] [/a[[:]attributes]][/o[[:]sortorder]] [/t[[:]timefield]] [/s] [/b] [/l] [/n] [/x]
Parameters
none
Used without parameters or switches, dir 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.
[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. Multiple filenames can be used. Filenames can be separated by spaces,
commas, or semicolons.
/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.
/d
Same as wide but files are sorted by column.
/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
s System files
d Directories
a Files ready for archiving (backup)
r Read-only files
-h Files that are not hidden
-s Files other than system files
-d Files only (not directories)
-a Files that have not changed since the last backup
-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
e In alphabetic order by extension
d By date and time, earliest first
s By size, smallest first
g With directories grouped before files
-n In reverse alphabetic order by name (Z through A)
-e In reverse alphabetic order by extension (Z through A)
-d By date and time, latest first
-s By size, largest first
-g With directories grouped after files
/t[[:] timefield]
The following list describes each of the values you can use for timefield.
Controls which time field is displayed or used for sorting.
c Creation
a Last access
w Last written
/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.
/n
Displays long list format with filenames on far right.
/x
Displays the shortnames generated for files on NTFS and FAT volumes. Display
is the same as with the /n switch, but shortnames are displayed after the longname.
See Also
Tree
More Information About Dir
Dir--Notes
Dir--Examples