The listing of folder contents can be done with the dir command. This command allows you to see the available files and directories in the current directory. The dir command also shows the last modification date and time, as well as the file size.
DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]
|S.No.||Options & Description|
Specifies drive, directory, or files to list
Displays files with specified attributes.
D - Directories R - Read-only files
H - Hidden files A - Files ready for archiving
S - System files I - Not content indexed files
L - Reparse Points - Prefix meaning not
Uses bare format (no heading information or summary).
Displays the thousand separator in file sizes. This is the default. Use /-C to disable the display of the separator.
Same as wide but files are list sorted by column.
New long list format where filenames are on the far right.
Lists by files in sorted order.
N By name (alphabetic), S By size (smallest first), E By extension (alphabetic), D By date/time (oldest first), G Group directories first - Prefix to reverse order
Pauses after each screen is full of information.
Displays the owner of the file.
Displays alternate data streams of the file.
Displays files in the specified directory and all subdirectories.
Controls what time field is displayed or used for sorting.
C - Creation
A - Last Access
W - Last Written
Uses wide list format.
This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place.
Displays four-digit years.
Let’s see some of the examples on how to use the DIR command.
The above command lists any file that ends with the .exe file extension.
dir *.txt *.doc
The above command uses multiple filespecs to list any files ending with .txt and .doc in one command.
Lists only the directories in the current directory. If you need to move into one of the directories listed use the cd command.
Lists the files in the directory that you are in and all sub directories after that directory. If you are at root "C:\>", type this command, this will list to you every file and directory on the C: drive of the computer.
If the directory has lots of files and you cannot read all the files as they scroll by, you can use the above command and it displays all files one page at a time.
If you don't need file information you can use the above command to list only the files and directories going horizontally, taking as little space as needed.
dir /s /w /p
The above command will list all the files and directories in the current directory and the sub directories, in wide format and one page at a time.