Quincy Center for Technical Education
Computer Technology Department

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] [/c]

Parameters

none

Used without parameters or switches, dir displays the disk's volume label and serial number, followed by a list of directories and files on the disk, including their names and the date and time each was last modified. For files, dir displays the name extension and the size in bytes. Dir also displays the total number of files and directories 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 file names can be used. File names can be separated by spaces, commas, or semicolons. You can use wildcard characters (? and *) in the filename parameter to display a group of files.

/p

Displays one screen of the listing at a time. To see the next screen, press any key on the keyboard.

/w

Displays the listing in wide format, with as many as five file names or directory names on each line.

/d

Same as /w 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.

Value

Description

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 file names. 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.

Value

Description

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 (.ZZZ through .AAA)

-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.

Value

Description

c

Creation

a

Last access

w

Last written

/s

Lists every occurrence, in the specified directory and all subdirectories, of the specified file name.

/b

Lists each directory name or file name, one per line (including the file name 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 short names generated for files on NTFS and FAT volumes. The display is the same as with the /n switch, but short names are displayed after the long name.

/c

Displays the thousand separator in file sizes.