DIR Command – List Files in Windows Command Prompt
dir command is used to list files and folders in the Windows command prompt (CMD).
dir command without a path will display a list of files and folders in the current working directory.
You can provide a path to see the listing for a different directory:
By default, the
dir command does not show hidden files and folders. To include hidden files, run the
dir command as follows:
You can use the
/B switch to show the file names only without heading information or summary.
dir /b C:\Windows
/s option lists all files in a specified directory and all subdirectories.
List Files Using Patterns
dir command supports wildcard character (
*) that you can use to describe a pattern to match.
For example, the following command lists all files that begin with the letter A:
Here is another example that lists all files that have a
dir /b *.doc
Displays files with specified attributes
/A switch is used to list files and folders with specified attributes. For example, the letter
H represents the hidden attribute.
The following table describes each of the values that you can use for Attributes.
|Hidden files and Folders.
|Files ready for archiving.
|Not content indexed files.
|Prefix meaning not (See examples).
List Files and folders in
Obtain a listing of all files in
C:\Windows\System32 that ends with the .txt extension:
Search for files with
.dll extension in
C:\Windows\System32 and all subdirectories:
dir /s C:\Windows\System32\*.dll
Returns the listing for the parent directory of the current working directory:
List all files and folders, including hidden files:
Show hidden files only:
List only folders:
Don't list folders:
Show only hidden folders:
List read only files:
Sort the result by name:
This will sort the result set by size:
Sort the result set by size (largest first):
Sort the result by date:
Includes the name of the owner for each file:
Show creation time:
Show last access time:
Show the last written time:
dir /? command to see a list of all the available command-line options.