How to List Files in Command Prompt

So you want to know how to list files in Command Prompt, do you? Well, you’ve come to the right place!

If you’re a Windows user, you’re probably familiar with the Command Prompt. It’s a powerful tool that lets you access your computer’s file system and carry out various tasks, such as creating, renaming and deleting files and folders. Another task you can do in Command Prompt is listing the files and directories within a specific folder. In this article, we’ll show you how to do just that.

Note On Other Operating Systems

While this guide has been specifically written for using Command Prompt on Windows, you can use similar commands on Mac OS and Linux to list files. On Mac OS, you can use the ls command in the Terminal, and on Linux, you can use the ls command in the Terminal or Console.

How to List Files in Command Prompt

How to List Files in Command Prompt

Total Time: 1 minute

Open Command Prompt

The first step is to open the Command Prompt. You can do this by clicking the Windows button and typing ‘cmd’ into the search bar. Then, click on the Command Prompt application to open it.

Change the Directory

change directory command prompt

Once you’re in the Command Prompt, you’ll need to navigate to the directory that contains the files you want to list. To change the directory, use the cd command followed by the path to the desired folder.

For example, if you want to list the files in a folder called ‘Test’ in the root of your c:\ drive, you would type

cd c:\Test

and press enter

List Files

Now that you’re in the correct directory, you can list the files using the dir command.

Simply type;

dir

and press enter to see a list of all the files and folders in the current directory!

How to Sort Files listed in Command Prompt

Whilst it’s useful to be able to list files, it’s also useful to be able to sort them too!

In our example the files are all prefixed with a number which makes them appear in a logical order, but that wouldn’t always be the case.

If you want to sort the files, you can use the /O switch with the dir command.

You can order by the following attributes

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

For example, to sort the files in alphabetical order, you would type

 dir /O:N 

And press enter.

Conclusion

And there you have it, a simple and straightforward guide on how to list files in Command Prompt. It’s a simple but useful trick that can come in handy in many situations. Whether you’re a seasoned Command Prompt user or a beginner, this guide should help you get the most out of this powerful tool. So, give it a go and see what files and directories you can uncover!

Leave a Comment