DIR
(from Directory)
Lists files and subdirectories inside a directory.
DIR [drive:][path][filename] [/A[[:][-]attr1 [[-]attr2 [...]]]] [/B] [/[-]C] [/D] [/L] [/N] [/O[[:][-]order]] [/P] [/Q] [/S] [/T[[:]date_field]] [/W] [/X] [/4]
Where:
[drive:][path][filename]
- Specifies drives, directories, and/or files to list./A[[:][-]attr1 [[-]attr2 [...]]]
- Displays files with the specified attributes (see ATTRIBATTRIB and DEL or ERASEDEL or ERASE). The-
sign in front of the specified attribute hides elements with that attribute. Replaceattr1
,attr2
, etc… with:D
- Directories.R
- Read-only files.A
- Archive files.S
- System files.H
- Hidden files.I
- Not indexed files.T
- Temporary files.O
- Offline files.L
- Symbolic links.C
- Compressed files.E
- Encrypted files.X
- Clean files.V
- On ReFS volumes (introduced in Windows 8): Healthy files; on FAT volumes: Deprecated.P
- Since Windows 10 v1703: pinned files (always available on OneDrive); before Windows 10 v1703: sparse files (disk allocation only for non-null data).U
- Unpinned files (online only on OneDrive, introduced in Windows 10 v1703).M
- Strictly sequential files (introduced in Windows 10 v1703).B
- Recall on data access files (introduced in Windows 10).
/B
- Lists files without header or summary information./C
- Displays thousands separator in file sizes (default)./-C
- Disables/C
./D
- Displays in wide format, files are sorted by column./L
- Uses lowercase characters./N
- New long format, with file names on the right./O[[:][-]order]
- Lists files in sort order. The-
sign in front of the sort order reverses the sort order (e.g.-N
). Replacesort
with:N
- By name, from A to Z.S
- By size, from smallest to largest.E
- By extension, from A to Z.D
- By date and time, oldest to newest.G
- Shows directories first.
/P
- Shows the list one screen at a time./Q
- Shows the owner of the file./S
- Shows files in the directory and its subdirectories./T[[:]date_field]
- Checks displayed date field. Replacedate_field
with:C
- Creation.A
- Last access.W
- Last writing.
/W
- Displays in wide format./X
- Shows generated contracted names for long format names./4
- Shows the year in four digits.
By setting the DIRCMD
environment variable you can specify default options, which can be disabled with a -
sign in front, for example (see SETSET):
rem Display the list of files and directories in standard format for the current directory
dir
set dircmd=/w
rem View in wide format (/W option is preset by DIRCMD)
dir
rem Display in standard format again (by turning off /W)
dir /-w
Examples:
1. Display files in the directory C:\1001 directories
sorted by name from Z to A, not displaying hidden ones, showing the creation date:
dir "C:\1001 directories" /a:-d -h /o:-n /t:c
2. View subdirectories of the directory C:\1001 directories
sorted by column size from smallest to largest, with last access date:
dir "C:\1001 directories" /a:d /c /o:s /t:a
Comments