MS-DOS and Windows command line dir command

MS-DOS and Windows control line dir command

Updated:
12/30/2021
by

Calculator Hope

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

Availability

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

Description

The
dir
command displays a list of files and subdirectories in a directory. With the
/S
option, information technology recurses subdirectories and lists their contents also.

Options listed beneath may exist preset in the
DIRCMD
environs variable. To override preset options, prefix any switch with – (hyphen), for example, “/-West“.

Syntax

The syntax of the
dir
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]
[Drive
:][Path][FileName]
Specifies the drive, directory, or files to list. Multiple filespecs are immune, e.g., “*.txt *.exe“.
/A:
Attributes
Displays only files with the specified file attributes.
Attributes
is a series of letters, each representing an attribute every bit shown below.

D
: Directories.
R
: Read-but files.
H
: Subconscious files.
A
: Files marked ready for archiving.
Southward
: Organization files.
I
: Non-indexed files.
L
: Reparse points.

: Prefix meaning “non”.

For example, the selection “/A:R-A” would match only files whose attributes (/A:) are read-only (R) and
not
() ready to be archived (A).

/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
/-C
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.
/O:
SortOrder
Sort the list of files by
SortOrder, a series of letters representing sort criteria.

N
: By name (alphabetic).
Due south
: By size (smallest first).
Eastward
: By extension (alphabetic).
D
: By date/time (oldest kickoff).
G
: Grouping directories outset.

: Prefix to reverse gild.

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.
/T
TimeField
Specify the fourth dimension field displayed and used for sorting.
TimeField
may exist any of the following letters.

C
: Creation fourth dimension.
A
: Terminal access time.
W
: Final write time.

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
/Due north
(“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.
Popular:   MS-DOS and Windows command line calcs command

Windows ME, 98, 95, iii.10, and MS-DOS syntax

        DIR
        [Bulldoze
        :][Path][FileName] [/P] [/Westward] [/A[[:]attributes]] [/O[[:]sortorder]] [/South]     [/B] [/Fifty] [/5]
[Bulldoze
:][Path][FileName]
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.
/A[:
Attributes]
List only files with the specified file attributes.
Attributes
is a series of letters indicating.

D
: Directories.
R
: Read-only files.
H
: Hidden files.
A
: Files set up for archiving.
S
: Arrangement files.

: Prefix pregnant “not”.

/O[:
SortOrder]
Listing files in sorted gild, indicated by
SortOrder.

North
: By proper name (alphabetic).
Due south
: Past size (smallest beginning).
E
: By extension (alphabetic).
D
: By date and time (primeval first).
Grand
: Grouping directories first.

: Prefix to reverse gild.
A
: By terminal admission date (earliest offset).

/South List files and directories recursively, traversing subdirectories.
/B Uses blank format (no heading information or summary).
/L Uses lowercase.
/V Verbose mode. Display extra information.

Examples

dir

Lists all files and directories in the electric current directory.

dir *.exe

Lists whatever file whose name has the file extension “.exe“.

Note

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

dir /a:d

Lists but directories.

dir /a:r

List only files with the read-only attribute.

dir /s

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.

dir /p

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.

dir /o:northward

Lists files and directories in the current directory in alphabetical order. This example is the same as but running
dir
considering files and directories are listed in alphabetical lodge by default.

dir /o:-n

Lists files in
reverse
alphabetical gild.

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
dir
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,
detect
also displays the number of files in each directory, and the amount of space occupied by each.

dir > myfile.txt

Runs the
dir
command, simply redirects the output to the file
myfile.txt, instead of displaying it on the screen. Here, the
dir
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
type
command.

type myfile.txt

If the file is very long, yous can pipe
type
to
more, and so information technology pauses after each screen.

blazon myfile.txt | more than

Popular:   Adobe Photoshop Help

Source: https://www.computerhope.com/dirhlp.htm