Home » How to Get the Size of a Directory in CMD

How to Get the Size of a Directory in CMD

You can use the following syntax in Command Prompt (CMD) to get the size of a directory:

dir /S

This example will list all files and subdirectories in the current directory and provide a summary at the end, including the total size.

Note: The /S flag specifies to include all subdirectories.

The following example shows how to use this syntax in practice.

Example: Getting the Size of a Directory in CMD

Suppose that we want to get the size of the following directory:

C:\Users\admin\Documents\cmd_script

We can type the following command to get the size of the directory:

dir C:\Users\admin\Documents\cmd_script /S

The following screenshot shows how to use this syntax in practice:

Get the size of directory
Get the size of the directory

We can see that the total size of C:\Users\admin\Documents\cmd_script is displayed at the end of the output.

Conclusion

We can use the dir command followed by the path and the /S flag to get the size of any directory on the system.

You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.