In the Windows command line, the dir command is used to list files and directories. The dir command is similar to the ls command used in Unix-like operating systems.
The command is very helpful while navigating from one directory to another in the Windows filesystem. While moving from one directory to another if you don’t know exactly where to go then you can use the dir command and see the list of files and folders.
Today in this article I will discuss how to list files and directories in Windows command prompt or PowerShell.
How to use the dir command in cmd
The syntax of using the dir command in Windows is given below –
The example of using the dir command is given ahead in this article.
List files & directories of your current working directory
The current working directory is a folder where you are currently working. You can view all the files and directories inside your current working directory by using the given command –
You can see the output of this command in the image below –
Using switches with the dir command
You can extend the functionality of the dir command by using switches. An example of using a switch is given below –
dir d:\software\TinyCore-* /Q
Where /Q is a switch that displays the file owner information. Now see the below image –
Similarly, you can use /A followed by a letter code to display files with a specific attribute. The letter code is given below –
D – This will display all the directories in the current path
R – Display read-only files
H – Use to display hidden files
A – Files ready for archiving
S – System files
I – Not content indexed files
L – Reparse points
O – Offline files
For a detailed list of switches that can be used with this command run the following command in your command prompt –
Hopefully, this article is useful to you. In case you have a query or feedback then write us in the comments below.