4 Ways To Count The Number Of Folders And Files Inside A Folder

There are times when you need to know exactly how many files or folders are stored inside a certain folder. Whether for work or for your own statistics, if you have a Windows device, there are quite a few ways in which you can find this information. Since some of our readers asked us about it, we decided to write a roundup article in which we're going to show you all the methods we know for counting the elements found inside a folder.

NOTE: The methods for counting files and folders we'll show in this article work in a similar way in Windows 10, Windows 8.1 and Windows 7. For simplicity reasons, we'll only use screenshots taken in Windows 10.

Method 1. Use File Explorer To Select The Files And Folders You Want To Count

The first method involves the use of File Explorer/Windows Explorer. Open File Explorer and browse to the folder where the items you want to count are stored.

The total number of items (both files and folders) stored inside is displayed in the lower left corner of File Explorer's user interface.

If you want to count only some of the files or folders stored inside your folder, select all of them and look at the bottom left side of the File Explorer interface. It will display the number of selected items.

Method 2. Use The Properties Window To Recursively Count All Files And Folders

While the previous method is certainly useful in many cases, it doesn't work recursively. It counts the files and folders on the first level of the folder tree, but these folders most likely contain other files and folders inside. What if you want to know exactly how many folders and files are stored inside a certain folder and all its subfolders? An easy method to find this information is to use the Properties window of the selected folder. Right click or tap and hold on the folder's icon. In the contextual menu, click or tap on Properties.

Note that an even faster way to open the Properties window of a folder is to select it and then simultaneously press the Alt + Enter keys on your keyboard.

When the Properties window is opened, Windows will automatically start counting the files and folders inside the selected folder. You'll see this information displayed in the Contains field.

Method 3. Use The Command Prompt To Recursively Count All The Files And Folders

You can also use the Command Prompt. To count the folders and files stored inside a certain folder, open the Command Prompt and navigate to that folder. To do that, run the command cd [path], where [path] is the location of your folder. You can see an example in the screenshot below and, if you want more details about the basic commands you can use in Command Prompt, check this guide also: Command Prompt - How to Use Basic Commands.

Then, to count all the folders and files inside your parent folder, run the following command:

dir *.* /w /s

After you press Enter, the Command Prompt will list all the files and folders inside your parent folder and, at the end, it will show you a summary of its contents. This summary will also show exactly how many files and folders are stored in your folder. Note that this information is recursive - it includes all subfolders and all files.

Method 4. Use PowerShell To Count All The Files And Folders

Another geeky way of counting the files and folders stored inside a parent folder is to use PowerShell. Open a PowerShell window and head to the location of your parent folder. Run the command cd [path], where [path] is your folder's path. Here's an example:

If you want to count all the items inside your folder, regardless of whether they are files or folders, run the following command. Note that it doesn't work in a recursive manner, it only counts the first level elements.

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

If you want to count only the folders inside your parent folder, run this command:

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

If you want to know only the number of files, run this command:

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

If you want to recursively count folders and/or files in your parent folder, add the Recurse parameter to the previous commands, as follows:

  • Recursively count all files and folders: Get-ChildItem -Recurse | Measure-Object | %{$_.Count}
  • Recursively count only folders: Get-ChildItem -Recurse -Directory | Measure-Object | %{$_.Count}
  • Recursively count only files: Get-ChildItem -Recurse -File | Measure-Object | %{$_.Count}

Conclusion

If you want to know exactly how many files and folders are inside a certain folder from your Windows computer, now you know how to do it. As you've seen, there a couple of ways in which you can find this information, so you can choose whichever fits best. If you have questions, or if you know of other ways to find this information, don't hesitate to leave us a comment below.