In this post, you can learn what DIR command is, DIR command functions and how to use DIR command in Windows 10/8/7. If you need a data recovery tool, hard drive partition manager, Windows backup and restore program, you can turn to MiniTool software.
What Is DIR Command?
DIR command is a Command Prompt command. You can type this command in Windows Command Prompt to display information about all files and subfolders in the current directory. It shows the file name, size, last modification date and time of each file.
DIR command is available in Command Prompt of all Windows systems incl. Windows 10/8/7/Vista/XP. Older versions of Windows also have the DIR command but have fewer options. The DIR command is also included in all versions of MS-DOS.
You can type DIR command itself to display the files and folders in the current directory. If you want to extend DIR command functions, you can use various switches and options related to this command to conduct different operations to files/folders. The DIR command can be executed alone.
How to Use DIR Command in Windows 10/8/7
DIR /A
The most commonly used DIR command line is /A. You can add a specific file attribute after /A to only display files with the specific file attribute. The file attributes are represented with a series of letters and each of them stands for a different file attribute, you can check then below.
- D: List all directories in the current path
- R: Show read-only files
- H: Show hidden files
- A: Archive files
- S: List system files
- I: Not content indexed files
- L: Reparse points
- -: Add a minus in front of any of the file attribute to let the DIR command not show that kind of file.
You can add a specific file attribute after /A to display certain files. You can check the examples below.
dir: list all files and directories in the current directory.
dir *.exe: list all files with the file extension .exe.
dir *.exe *.doc: list all files with the file extension .exe and .doc.
dir /ad: list all directories in the current path.
dir /ash: show hidden system files.
dir /a-d: list all files but no directories.
dir /a:r-a: display all read-only non-achieve files.
DIR /B
You can type this DIR command to only display the directory name, file name and extension in the current directory.
DIR /O
You can use this command to display results in a sorted order. You can add a letter code below after the /O switch to sort the displayed result.
- D: Sort result by date/time. The oldest file shows first.
- E: Sort result by file extension in alphabetical order.
- G: Sort result by listing folders first, and then list files.
- N: Sort result by the name of file/folder in alphabetical order.
- S: Sort result by file size, from the smallest size to largest size.
Tip: You can add a minus – to any of the above letter code to reverse the display order, e.g. dir /o–d, this will sort the display result by time and date, and the newest file displays first.
Conclusion
For more DIR commands and their usages, you can refer: Dir Command.
If you need to recover deleted or lost files from computer or other storage devices, you can use the best free data recovery software – MiniTool Power Data Recovery.