Computer

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

Windows files

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 (no admin permissions required 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 inside 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

number of cmd files

The number of folders shown, we must divide it 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 sizewe will add the command “/os”

dir /s /os

Using this command, we can also create a file listing 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 we need to use it is much more complexbut, 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 the directories.

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

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

number PowerShell files

Yes, we want to know only the number of foldersthe 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 supported starting with 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 clicking on 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 know which are the files that more space are occupying on our hard drive, and it will help us organize its content, since it also allows us to delete, copy and move files and folders.

witztree

An important point that this application offers us and that we do not find in other alternatives is that it is available in portable version, so it is not necessary to install to take advantage of the functionality 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 an app free 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 drive is the WinDirStat application. As we can well deduce from the name, this application offers us statistics about 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 column filesthe number of files is shown while the number of subfolders is found in the column Subdir.

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

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *