Command Prompt for Windows

Command DIR


Displays a sorted list of files and sub-directories in a directory.


DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/D] [/F] [/J] [/L] [/N] [/O[[:]order]] [/P] [/S] [/T[[:]timefield] [/V] [/W] [/X] [/4]
[drive:][path][filename]Specifies the drive, directory, and/or files to list.
/ADisplays files with specified attributes, where attributes are :-
RRead-only files
HHidden files
AArchive files
SSystem files
-Prefix meaning NOT
/BUses bear format (only display file names).
/DSame as wide directory list but sorted into columns instead of rows.
/FUses 8.3 file name directory format, when possible.
/JRight justified file name extensions for 8.3 file names.
/LDisplay file names in lower case.
/NUses new long file name directory format.
/ODisplay files sorted in the specified order, where order is :-
GGroup directories first
NBy name (alphabetic)
EBy file extensions
DBy file date and time (earliest first)
SBy file size (smallest first)
-Prefix to reverse the order
/SProcess sub-directories.
/TDisplay or sort on this timefield. where timefield is :-
ALast access
/VDisplay Volume Name and Serial Number.
/WUses wide list format.
/XDisplay short filename equivalents next to the long filename. If no short filename exists, then spaces are displayed instead.
/4Force the displaying of 4 digit file dates.


When the /F switch is specified and a directory contains files that conform to the 8.3 file naming convention, then regardless of the file system, the directory listing will be formatted with file names on the left hand side of the listing, otherwise the new long file name directory format is used. In the new long file name directory format the file names appear on the right hand side of the listing.

Switches that are preset in the DIRCMD environment variable are ignored.

Also see command JUNCTION, ATTRIB and DEVICES.