- Dir display a list of a directory's files and sub directories.
- Dir display the disk's volume label and serial number followed by a list of directories and files on the disk with name, date and time each was last modified.
- For files dir displays the name extension and the size in bytes.
- It also displays the total number of files and directories listed, their size and the free space remaining on the disk.
Syntax
Dir [Drive:][Path] [FileName] [/p] [/q] [/w] [/d] [/a[[:]Attributes]] [/o[:]SortOrder]] [/t[[:]TimeField]] [/s] [/b] [/l] [/n] [/x] [/c] [/4]
[Drive:][Path]
- Specifies the drive and directory for which you want to see a listing.
[FileName]
- Specifies a particular file or group of files for which you want to see a listing.
- You can use multiple filenames. Separate file names with spaces, commas or semicolons.
- You can use wildcard characters (? and *) in FileName to display a group of files or directories.
/p
- Displays one screen of the listing at a time. To see the next screen, press any key on the keyboard.
/q
- Display the ownership information.
/w
- Display the listing in wide format.
/d
- Same as /w but files are sorted as column.
/a [[:] Attributes]
- Displays only the names of those directories and files with the attributes you specify.
- If you omit /a, dir displays the names of all files except hidden and system files.
- If you use /a without specifying attributes, dir displays the names of all files, including hidden and system files.
- If you use /a with more than one value in attributes, dir displays the names of only those files with all the specified attributes.
Attributes
Value |
Description |
h | Hidden files |
s | System files |
d | Directories |
a | Files ready for archiving |
r | Read-only files |
-h | Files that are not hidden |
-s | Files other than system files |
-d | Files only (not directories) |
-a | Files that have not changed since the last backup |
-r | Files that are not read-only |
/o [[:]SortOrder]
- Controls the order in which dir sorts and displays directory names and file names.
-
If you omit /o, dir displays the names in the order in which they occur in the directory.
- If you use /o without specifying SortOrder, dir displays the names of the directories and then displays the names of files sorted in alphabetic order.
Sort order
Value |
Description |
n | In alphabetic order by name |
e | In alphabetic order by extension |
d | By date and time, earliest first |
s | By size, smallest first |
g | With directories grouped before files |
-n | In reverse alphabetic order by name (Z through A) |
-e | In reverse alphabetic order by extension (.ZZZ through .AAA) |
-d | By date and time, latest first |
-s | By size, largest first |
-g | With directories grouped after files |
/t [[:]TimeField]
- Specifies which time field to display or use for sorting.
- The following list describes each of the values you can use for TimeField.
Value |
Description |
c | It will display according to creation time or date |
a | Display according to last access |
w | According to last written |
/s
- Lists every occurrence, in the specified directory and all sub directories, of the specified file name.
/b
- Lists each directory name or file name, one per line, including the file name extension.
- /b does not display heading information or a summary, /b overrides /w.
/l
- Displays unsorted directory names and file names in lowercase.
- /l does not convert extended characters to lowercase.
/n
- Displays a long list format with file names on the far right of the screen.
/x
- Displays the short names generated for files on NTFS and FAT volumes.
- The display is the same as the display for /n, but short names are displayed after the long name.
/c
- Displays the thousand separator in file sizes.
/4
- Displays four-digit year format.
/?
- Displays help at the command prompt.
Using command redirection operator
- Redirection operators are used to redirect command input and output streams from the default locations to different locations.
Value |
Description |
> |
Writes the command output to a file or a device, such as a printer, instead of the Command Prompt window. |
< |
Reads the command input from a file, instead of reading input from the keyboard. |
>> |
Appends the command output to the end of a file without deleting the information that is already in the file. |
>& |
Writes the output from one handle to the input of another handle. |
<& |
Reads the input from one handle and writes it to the output of another handle. |
| |
Reads the output from one command and writes it to the input of another command. Also known as a pipe. |
My notes
No comments: