How to Count Number of Files or Subfolders Inside a Folder

Gaurav Bidasaria

While I've moved my data to Google Drive, I still have a lot on my hard drive. Checking the subfolders and files that exist inside the main folder is tedious. I am sure all of us have come across this situation at some point in time.

Count Number Of Files Or Subfolders


That can be troublesome, mainly if there are many subfolders inside subfolders with files saved inside them. You can’t count them manually. Too cumbersome, and boring! To counter this issue, I will share with you some methods to find not only the total number of subfolders that lies inside a folder but also the total number of files inside them.

Let’s begin.

1. View Properties

This is probably one of the easiest methods to know what lies within that folder. You won’t need any additional software for it either. Just locate the folder, or the subfolder, for which you need to count the subfolders or files, right-click on it, and then click on Properties from the context menu. You can also press ALT+Enter to open the Properties of a folder or a subfolder.

Count Number Of Files Or Subfolders 1

Depending on your computer's make and model, and the size of the folder, Windows may take a few moments to calculate. Once it is ready, you can view the total size of the primary folder, the subfolders inside it and the number of files inside those folders as well as subfolders.

Count Number Of Files Or Subfolders 2
Note: There is an option to count hidden files and subfolders too as seen in the screenshot above. If you did not hide any of them manually, then I recommend you not to fiddle with this setting.

2. Use File Explorer

File Explorer lets you browse all the files and folders inside your hard drive. You can directly launch it by pressing Windows Key+E shortcut or go to My Computer and select the correct partition. File Explorer can also be used to quickly find the number of subfolders or files inside a particular folder.

Open the folder and select all the subfolders or files either manually or by pressing CTRL+A shortcut. If you choose manually, you can select and omit particular files.

Count Number Of Files Or Subfolders 3

You can now see the total count near the left bottom of the window. Repeat the same for the files inside a folder and subfolder too. It is useful when you need to know the total count inside one particular folder.

3. Command Prompt

Quite a few Windows users enjoy using the command prompt. It can be a powerful tool if you know how to use it and remember the correct commands. This one is for those who use the command prompt. Press the Windows key and type RUN to open the Run dialog box. Type cmd and hit enter to launch the command prompt.

Count Number Of Files Or Subfolders 4

You'll see a new window with a black background and white text. Now you have to enter the path where the folder is located. First, I will use the CD command to change the drive from C to H because the command prompt opens to point at the C drive by default. I type CD/ to go back to the root folder of C Drive and type the drive letter with a colon (H:) to change the drive. Then enter the folder path preceded by the CD command to open the desired folder.

Count Number Of Files Or Subfolders 5

Like the CD command is used to change directory, DIR command is used to work with directories. To count all the files and subfolders inside a parent folder, or directory, type the following command.

dir *.* /w /s
Count Number Of Files Or Subfolders 6

Don’t worry if you see the text scrolling automatically. In the end, you can see the total number of files and directories (subfolders) inside the primary folder. That includes all the files and folders as the command is recursive.

Count Number Of Files Or Subfolders 7

4. PowerShell

Feeling a bit geeky? For advanced users, there is the PowerShell which is one step above what we saw with the command prompt when it comes difficulty level. Use the Windows search feature to find Windows PowerShell and click on it.

Count Number Of Files Or Subfolders 8

You will see a new window pop up with a blue background this time. Navigating to your desired folder is easier in the PowerShell. Just type cd followed by your folder structure.

cd h:\database
Count Number Of Files Or Subfolders 9

To count all the files or subfolders inside the parent folder, copy and paste the following command.

Get-ChildItem | Measure-Object | %{$_.Count}

You will notice that the result I got above is different. This is because the command is not recursive which means it will not go deeper than one level. So, there are 5 subfolders.

Count Number Of Files Or Subfolders 10

To recursively count all files and folders:

Get-ChildItem -Recurse | Measure-Object | %{$_.Count}

To recursively count only folders:

Get-ChildItem -Recurse -Directory | Measure-Object | %{$_.Count}

To recursively count only files:

Get-ChildItem -Recurse -File | Measure-Object | %{$_.Count}
Count Number Of Files Or Subfolders 11

5. WizTree

Finally, let’s take a look at a software that will not only make life simpler but also help gain insight on the type of files you have inside the folder. WizTree is a hard drive analyzer that collects many data metrics like file extension and their respective count, space taken by each format, and by individual files and folders.

Count Number Of Files Or Subfolders 12

If you click on the little ‘+’ icon next to a folder, it will show you the tree structure with their individual details. So you can easily drill down through the hierarchy of the folders and subfolders without having to go back and forth between them.

Know the Count

As discussed above, there are quite a few ways to count the number of files and folders or subfolders inside the main folder. Depending on your needs, you may choose either the built-in Windows Explorer or the more powerful WizTree software that will also share other details in a tree-like structure.

Next up: Do you use Skype on Windows 10? Learn how you can record Skype calls for important meetings or conversations.

Read Next
How to Record Skype Calls on Windows 10
Also See
#windows 10 #File Explorer

Join the newsletter

Gaurav is a tech enthusiast who loves talking about new gadgets and innovations. He dropped out of CA because he found the work life boring and monotonous! He recently started working out but mostly, you will find him on the couch either Netflix-ing or gaming.