How to know the number of files and subfolders in a directory

Knowing the number of files and subfolders that are inside a folder can help us consider if it is necessary to establish an organization in our file system to make it much easier to find the files we are looking for quickly without having to resort to the file system. Windows searches either through File Explorer or the Windows search box.

As usual, to check if our file system needs an improvement, we have different methods at our disposal, methods that range from using Windows’ own functions, to using the command line and third-party applications. The important thing is to get the information we need to start putting our digital Diogenes in order.

know the number of files and subfolders in a directory

from Windows

The fastest and easiest method to find out the number of files and subfolders inside a folder is by using the file explorer. The process is as simple as opening the file explorer, clicking with the right mouse button on the folder for which we want to know that information, and then accessing its properties .

The number of files and folders inside it is displayed on the General tab , just below the folder name and its location. From Windows we cannot export that information or the structure of the files in any way without resorting to a command prompt or third-party applications.

archivos Windows

Using CMD

Before the graphical interface that came with Windows 3.11, the only way to interact with MS-DOS, the predecessor of Windows, was using the command line. Currently, the command line is still essential to carry out certain processes, processes that, through the graphical interface, we cannot carry out. However, CMD, far from being forgotten, has managed to evolve, being PowerShell its successor within Windows. Unlike CMD, PowerShell allows you to create scripts to manage different computers on a network, a functionality that has never been available in CMD.

From the command line, we can know the exact number of both files and subfolders that are inside a folder. To know this information, the first thing we must do is open CMD ( administrator permissions are not needed since we are not going to make changes to the system).

From the command line, the first thing we must do is access the directory where all the files and folders whose number we want to know are located. To do so, we just have to use the commands “cd..” to access the previous directory and “cd folder name” to access the interior of a folder. To list the content of each folder we use the “dir” command.

Once we are inside the folder where we want to know the exact number of files and folders inside it, we will use the command

dir /s

número archivos CMD

The number of folders shown, we must divide by 3 to get the correct number. This is because the command line counts the commands “.” and “..” to work with directories, directories that obviously don’t exist in Windows.

If, in addition, we want the files to be displayed in order according to size , we will add the command “/os”

dir /s /os

Using this command, we can also create a list of files in a plain text document, to calmly analyze it and see how we can create a file structure that helps us manage all the files stored on the computer more efficiently. To create a text file with all the files and folders we will add the variable “>filename.txt”.

dir /s >listado.txt

With PowerShell

PowerShell, like CMD, also allows us to obtain the number of files and subdirectories inside it. But, unlike Command Prompt, the command that we must use is much more complex , but, unlike this one, it only shows us a number, a number that corresponds to the number of subdirectories or the total number of files in a folder , including those found in directories.

To know the total number of files in a directory, we must use the following command

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

número archivos PowerShell

Yes, we want to know only the number of folders , the command to use will be this

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

Using third party applications

Not only can we know the number of files and subfolders in a directory natively, but we can also use third-party applications like the ones we show you below.

Folder Size Explorer

Folder Size Explorer is a fantastic application to know the number of files and subfolders in a folder, since it allows us to know that information in detail in different measures: byte, kilobytes, megabytes, gigabytes or terabytes. In addition, unlike the previous methods, it also allows us to know, independently, the number of files included in each folder as well as the number of subfolders.

Folder Size Explorer

The user interface is very similar to that of the file explorer so we can quickly get familiar with it. Once we run the application, in the left section, we must select which directory we want to obtain that information from. In the right column, the name of all the directories stored inside it will be displayed, along with the number of files in each folder and the number of total subfolders.

Folder Size Explorer is compatible from Windows Vista in 32 and 64 bit versions and from Windows Server 2008. The download and use of this application is completely free for non-commercial use and we can download it directly from its website by pressing the following link .

WizTree

The WizTree application analyzes our PC every time we run it to show the number of files and folders stored on all the drives we select when starting the application. The operation of the application is similar to Folder Size Folder, showing us the number of files and subfolders included in a directory together with the total space they occupy. In addition, it also allows us to quickly find out which files are taking up the most space on our hard drive, and it will help us organize their content, since it also allows us to delete, copy, and move files and folders.

Wiztree

An important point that this application offers us and that we do not find in other alternatives is that it is available in a portable version , so it is not necessary to install it to take advantage of the functionality that it offers us. In addition, we can access a history of the versions of this application, so we can use it from Windows XP onwards.

WizTree is a free application for non-commercial use, it is updated periodically and will help us organize our file structure just like we can do directly with Windows Explorer, but knowing, at all times, the space occupied by the files and subfolders. We can download WizTree completely free of charge from its website .

WinDirStat

Another application that we have at our disposal to know the number of files and subfolders included in a folder or in a unit is the WinDirStat application. As we can well deduce from the name, this application offers us statistics about the Windows directories. The general operation of the application is very similar to that of Size Folder Explorer, however, WinDirStat offers us additional information graphically that allows us to know, at a glance, what type of applications are taking up space on our hard drive, although that information is not necessary for us at this time.

WinDirStat

The first time we run the application, it will invite us to select the drives on our computer that we want to analyze if we have more than one. Once we have confirmed which units we want to analyze, the application will scan all the information stored inside them to offer us the information we are looking for. One has analyzed the computer, we go to the previous directory where we want to know the number of files and folders. In the Files column, the number of files is shown while the number of subfolders is found in the Subdir column.

Downloading and using WinDirStat is completely free. The application is available through its website through this link .