How to...list and find files using command prompt

7 min read

What you need: Windows 10 or 11 Time required: 45 minutes

by Nick Peers

When using Command Prompt, have you ever needed to list the contents of a folder or drive? If so, then the DIR command has you covered. At first glance, that’s all it can do – and in a less visually accessible way than File Explorer. But dig a little deeper and you’ll find ways in which DIR can play a more active role: use it to quickly perform file searches, generate file lists you can open and edit in any text editor, and even confirm that your precious files are safe when Windows refuses to load. Here, we’ll explain how to use this powerful tool. Note that whenever we use yourname, you should replace it with your name as it’s registered in your Users folder (it’s ‘nickd’ in our screenshots).

1Learn the basics of DIR

To start, use DIR to list all files and folders in the current directory

Open Command Prompt (press Win+R, type cmd and press Enter) to find yourself in your personal user folder – for example, C:\Users\yourname. Type dir ( 1 in our screenshot) and press Enter. The command will first list the drive’s label if it has one – it’s ‘System’ in our example 2 . If there isn't one, you’ll see ‘Volume in drive C has no label’. Below that will be an alphabetical list of the contents of your user folder.

Information about each entry is split into five columns 3 : the first two show the date and time the file or folder was last modified – the same information that’s shown in File Explorer.

Next to this is a column that’s either marked <DIR> for a folder or left blank for a file, followed by a column that lists file size in bytes. The final column displays the folder or file name. These figures are always displayed in bytes, which isn’t the most practical figure to work with.

You can translate these figures into kilobytes (KB), megabytes (MB) or gigabytes (GB) with the help of a calculator: divide the number of bytes by 1,024 once for KB, twice (or 1,048,576) for MB, or three times (or 1,073,741,824) for GB.

At the bottom you’ll see the total number of files in the list and the space they take up; and the number of subfolders within this folder along with the amount of free drive space left.

If there’s a lot of content in the folder you’ve chosen, you’ll need to use the scrollbar on the right of Command Prompt (or your mouse wheel) to scroll back up the list. There are better ways to display this list, as we’ll see shortly.

On its own

This article is from...

Related Articles

Related Articles