MS-DOS and Windows control line dir command
command displays information near files and directories, and how much disk infinite is available. By default, it displays the name, size, and terminal modification fourth dimension of every file in the current directory.
Dir is an internal control bachelor in the control line of all Microsoft operating systems.
- All Versions of MS-DOS
- Windows 95
- Windows 98
- Windows ME
- Windows NT
- Windows 2000
- Windows XP
- Windows Vista
- Windows 7
- Windows 8
- Windows 10
- Windows eleven
command displays a list of files and subdirectories in a directory. With the
option, information technology recurses subdirectories and lists their contents also.
Options listed beneath may exist preset in the
environs variable. To override preset options, prefix any switch with – (hyphen), for example, “/-West“.
The syntax of the
command has evolved somewhat over time. Select your operating system to jump to the information that applies to your version.
- Windows 11, 10, 8, 7, Vista, XP, and 2000 syntax.
- Windows ME, 98, 95, iii.10, and MS-DOS syntax.
Windows xi, 10, 8, seven, Vista, XP, and 2000 syntax
DIR [Drive :][Path][FileName] [/A[[:]Attributes]] [/B] [/C] [/D] [/L] [/Northward] [/O[[:]SortOrder]] [/P] [/Q] [/R] [/S] [/T[[:]TimeField]] [/W] [/X] [/4]
|Specifies the drive, directory, or files to list. Multiple filespecs are immune, e.g., “*.txt *.exe“.|
|Displays only files with the specified file attributes.
is a series of letters, each representing an attribute every bit shown below.
For example, the selection “/A:R-A” would match only files whose attributes (/A:) are read-only (R) and
|/B||Uses bare format (no heading information or summary, only the information itself).|
|/C||Display the thousand separator in file sizes (east.k., a comma subsequently every third digit), which is the default setting. Employ
to disable the display of separator.
|/D||Same as wide (/W), but files are sorted by column, rather than past row.|
|/L||Uses lowercase in the output.|
|/Due north||“New long-listing” format, which displays file names on the far right.|
|Sort the list of files by
SortOrder, a series of letters representing sort criteria.
For example, an pick of “/O:D” displays files oldest-to-newest, and “/O:-S” displays files biggest-to-smallest.
|/P||Pauses after each screenful of information.|
|/Q||Display the possessor of the file.|
|/R||Display alternate data streams of the file.|
|/S||Displays files recursively, traversing whatever subdirectories.|
|Specify the fourth dimension field displayed and used for sorting.
may exist any of the following letters.
For example, when y’all apply the option “/T:C,” the time listed is when the file was created.
|/Due west||Uses broad list format, displaying file/folder names only, with multiple names on every line.|
|/X||Displays the short names generated for not-8dot3 file names. The format is that of
(“new long-list” format, see above), with the short name inserted earlier the long name. If no curt name is nowadays, blanks are displayed in its identify.
|/iv||Brandish years with four digits, e.g., 2018 instead of 18.|
Windows ME, 98, 95, iii.10, and MS-DOS syntax
DIR [Bulldoze :][Path][FileName] [/P] [/Westward] [/A[[:]attributes]] [/O[[:]sortorder]] [/South] [/B] [/Fifty] [/5]
|Specifies bulldoze, directory, or files to list. Multiple filespecs are allowed, eastward.g., “*.txt *.exe“.|
|/P||Pauses after each screenful of data.|
|/Due west||Uses wide list format.|
|List only files with the specified file attributes.
is a series of letters indicating.
|Listing files in sorted gild, indicated by
|/South||List files and directories recursively, traversing subdirectories.|
|/B||Uses blank format (no heading information or summary).|
|/V||Verbose mode. Display extra information.|
Lists all files and directories in the electric current directory.
Lists whatever file whose name has the file extension “.exe“.
Because of how the wildcard matching works, information technology’s too shows files with a file extension with iv or more characters (e.g., .exec).
dir *.txt *.doc
List whatsoever files whose name has the file extension “.txt” or “.physician“.
Lists but directories.
List only files with the read-only attribute.
Recursively lists files and directories in the directory, and in any subdirectories. For example, if your current directory is the root directory “C:\>,” this control lists every file and directory on the C: drive.
Pause later on each screenful of output. Use this option if the information is scrolling past the screen before you can read information technology. You are prompted to press whatever key before listing continues by the current screen.
dir /due west
Lists multiple file names on every line, producing “wide” output, which displays more file names at once. However, other information such as file size is omitted.
dir /s /due west /p
Recursively lists all files and directories in the electric current directory and whatever subdirectories, in wide format, pausing after each screen of output.
dir /s /west /p "C:\Program Files"
Same equally the higher up command, simply lists everything in
C:\Program Files, instead of the current directory. Considering the directory proper name contains a space, it is enclosed in double-quotes, to forestall it from being interpreted is as ii separate options.
Lists files and directories in the current directory in alphabetical order. This example is the same as but running
considering files and directories are listed in alphabetical lodge by default.
Lists files in
dir /s /q /a:sh /p C:\Windows
Lists any files and directories in
C:\Windows, and any of its subdirectories (/s), which take both the “hidden” and “system” file attributes (/a:sh). Too, lists the owner of the file (/q), and pauses later on each screen of output (/p).
dir \ /southward | notice "i" | more
The above control uses vertical bars to pipe the output from
to the control
find, and then to the command
more. The result is a list of all files and directories in the root directory of the current bulldoze (\), with extra information. Namely,
also displays the number of files in each directory, and the amount of space occupied by each.
dir > myfile.txt
command, simply redirects the output to the file
myfile.txt, instead of displaying it on the screen. Here, the
control has no options, but redirection works with whatever control you specify, then the following command also works.
dir /south /a:hs /q C:\Windows > myfile.txt
To view the contents of the file, you tin utilise the
If the file is very long, yous can pipe
more, and so information technology pauses after each screen.
blazon myfile.txt | more than