30 September 2011

DOS Dir Command and Its Parameters Reference



We can say that the dir command is one of the most fundamental DOS or Disk Operating System command that applied by a majority of the users. This command lists all the available files and directories in the specific directory path. It can also show the date and time of last change or modification that has been made on a file or directory and also the size of the file. The dir command first introduced as an internal command in the initial release of MS-DOS as a built in command of the DOS command shell.
If a user use dir command without any parameter or attribute, it shows the disk volume label and serial number, followed by the list of files and directories including with the name extension and size. In this post I intend to provide you the dir command syntax and all its parameters and attributes for your future references.


Syntax




Parameter
Description
Dir[dive:][path][filename]
Indicate the path or drive, directory and file name.
Dir/A
Shows files with specific properties.
H for hidden files, R for read-only files, D list directories, S system files, A files ready for archiving, I not content indexed files, L reparse points.
Dir/B
Only displays the file name and extension.
Dir/C
Display the file size without a sign, indicates three digits for separation.
Dir/D
Creates wide list format but lists the files in sorted columns.
Dir/L
Shows the file name in lowercase format.
Dir/N
Shows the list of files and files name on the right side.
Dir/O
To view files in sorted order.
N the name, S based on the size, E based on extension, D based on date or time, G groups directories first.
Dir/P
Shows list of the files page wise, to see the next page press any key on the keyboard.
Dir/Q
To display the owner of the file.
Dir/R
Shows alternate data streams of the file.
Dir/S
It shows all the files in the root and sub directories.
Dir/T
Specifies what time field displayed or sued for sorting.
C creation, A last access, W last written
Dir/W
For viewing the files name in columns or wide list format.
Dir/X
Displays the files in standard format (8 characters) in DOS environment.
Dir/4
Shows four digit years.


Examples


Shows file with specific properties: h for hidden files, r for read-only files, d list directories, s system files etc. example (dir/ah).



Only displays the file name and extension.



File size without a sign, indicates three digits for separation.



This command shows all the files in the root and subdirectories.



To view the files in the ordered format, use the attributes to sort the list base on the name, size, extension, date or time etc. for example (dir/on).



To view the list of files and directories in page wise format use this command, press any key to go to the next page.



Displays all files and subdirectories, in alphabetical order, wide format, and page wise (the p pauses after each screen, press any key to go to the next page).



Saves the list of files and directories in a text file called dir. Instead of dir.txt you can use any name like report.txt.



Lists all hidden files in drive C in a text file called the dir.txt.



Sends a list of all files in drive C to the printer.



List all files in the current directory that have the extension .txt. You can use the asterisk "*" for substitute any string of characters.



List all files in the current directory that have the extension .txt or .doc.