Windows OS

How to List Files in Windows Using Command Line

Files are used to store computer programs, textual documents, audio video streams, and libraries. In contrast, a folder is a unit to store files and is also called a directory. The file and folders are essential units of any computer system. In Windows, the folders and files can be listed using “dir” in the Command Prompt.

This tutorial will elaborate on the approaches to listing Windows files using the command line.

What is the “dir” Command?

dir” is derived from the word “directories” and is mainly used to list the file and directories of the system. Many options are available that are supported by the “dir” command in Windows to view different types of such files.

Check out the below-given table to have an idea about it:

Option Description
d View all directories
h View only hidden files
r View read-only files
s View all system files
i View indexed files

After having the basic information related to the “dir” command, let’s move ahead towards its implementation side.

How to List Files in Windows Command Line Using dir Command?

To list the files and folder in Windows with the help of the “dir” command, follow the provided instructions.

Step 1: Open Command Prompt

Press the “Window+R” key, type cmd, and press the “OK” button to open Command Prompt:

Step 2: List all Directories and Files

To view a list of all files and directories, simply use the “dir” command without any option:

>dir

Now, let’s take a look at some examples of using the “dir” command with the different options.

Example 1: View Only List of Folders

Utilize the “ad” options to view only a list of folders:

>dir /ad


Example 2: View Only List of Files

To view only a list of all files on the Windows command line, use the “” sign as “a-d”. The hyphen reverses the functionality of the added options:

>dir /a-d

Example 3: View List of Files and Folders in a Specific Directory

To view a list of files and folders in a specific directory, first, you need to move to that directory using the “cd” command. After that, utilize the “dir” command:

>cd C:\Users\anuma\OneDrive\Documents
>dir

Example 4: View List of Hidden System Files

The “s” option is used to display system files, and the “h” option is used to display a list of hidden files.
Therefore, to list all of the hidden system files, utilize the “ash” option in the “dir” command:

>dir /ash

Example 5: List All Folders and Files

List all system folders and files using the “s” option:

>dir /s

Example 6: List File and Folder by Specifying Wildcard

Use “v*” as a wildcard to view the list of files starting with the “v” alphabet:

>dir v*

We have illustrated the examples to list the files in Windows using the command line.

Conclusion

To list files in Windows using Command Line, first, open up the Command Prompt, then utilize the “dir” command. This will list the folders and files in the current directory. The “dir” command supports many options, which are practically demonstrated in different examples. This article demonstrated how to list files on Windows using the “dir” command.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.