How to Check Folder Size in Command?

Imagine your computer’s hard drive as a treasure chest of files and folders. Over time, this chest can fill up, and it’s essential to keep tabs on its contents. This guide will walk you through the process of checking folder size using command-line tools, ensuring you always know what’s taking up space on your storage device.

What is Folder Size?

Before delving into the technical aspects, let’s grasp the concept of folder size. Folder size refers to the total disk space occupied by a specific directory and its subdirectories. Understanding this is crucial for efficient storage management.

Why Check Folder Size?

Checking folder size is more than just a technicality; it’s a practice that can save you from storage-related headaches. By monitoring folder sizes, you can:

  • Identify and delete large, unnecessary files.
  • Prevent your hard drive from running out of space.
  • Optimize system performance.
  • Organize your data effectively.

Built-in Windows Commands

Windows users have access to several built-in commands for checking folder size via the Command Prompt. Let’s explore some of these commands and how to use them.

Command Prompt Basics

Before we proceed, let’s get comfortable with the basics of the Command Prompt. It’s a text-based interface where you can interact with your computer using commands.

Command 1: dir

The dir command is a fundamental tool for listing files and directories within a folder. To check the size of a specific folder, open the Command Prompt and type:

dir /s /ah <folder_path>

Command 2: du

Another useful command is du, which stands for “disk usage.” To check folder size using du, open Command Prompt and enter:

du -h <folder_path>

Command 3: tree

The tree command allows you to visualize the folder structure and size. Execute the following command:

tree /f <folder_path>

PowerShell Commands

For advanced users, PowerShell provides more robust options for checking folder size. Let’s explore two essential PowerShell commands.

Command 1: Get-ChildItem

To retrieve folder size with PowerShell, use the Get-ChildItem cmdlet. Execute the following command:

Get-ChildItem -Path <folder_path> -File -Recurse | Measure-Object -Property Length -Sum

Command 2: Measure-Object

Alternatively, you can calculate folder size directly using Measure-Object:

(Get-ChildItem -Path <folder_path> -File -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB

Linux Commands

Linux enthusiasts can leverage command-line tools to check folder size effortlessly.

Command 1: du

To check the size of a folder in Linux, use the du command with the -sh flags:

du -sh <folder_path>

Command 2: ncdu

For a more detailed analysis, consider using ncdu (NCurses Disk Usage). Install it and run:

ncdu <folder_path>

MacOS Commands

Mac users can also check folder size using the Terminal application.

Command 1: du

To check folder size in macOS, use the du command:

du -sh <folder_path>

Command 2: Third-party Apps

Additionally, you can explore third-party applications like DaisyDisk and Disk Inventory X for a more user-friendly experience.

How to Interpret Results

Interpreting the results of folder size commands is vital. Typically, the size is displayed in bytes or a more human-readable format like megabytes (MB) or gigabytes (GB).

  • dir and tree on Windows provide size in bytes.
  • PowerShell commands offer results in bytes, which can be converted to MB or GB.
  • Linux and macOS du commands show results in MB or GB.

Factors Affecting Folder Size

Folder size isn’t static; it can change due to various factors:

  • Adding or deleting files.
  • Compression and encryption.
  • Temporary and system files.

Understanding these influences is essential when managing disk space.

Best Practices

To efficiently check folder size, follow these best practices:

  • Regularly monitor folder sizes.
  • Use automated scripts for recurring tasks.
  • Keep your system clean by deleting unnecessary files.
  • Backup critical data to prevent data loss.


Encountering issues while checking folder size? Ensure you’re using the correct command syntax and have necessary permissions. If problems persist, consult online resources or seek professional assistance.


How often should I check folder sizes?

Regular checks are advisable, especially if you frequently add or remove files. Monthly or quarterly reviews can help maintain a well-organized system.

Can I check folder size for network drives?

Yes, you can check folder sizes for network drives using similar commands, but the process might be slower due to network latency.

What if the folder size command doesn’t work on my system?

Ensure that you have administrative privileges and are using the correct syntax. If the issue persists, consult your system administrator or refer to the documentation for your specific operating system.

Is there a way to automate folder size checks?

Yes, you can automate folder size checks using scripts and scheduling tools. This is especially useful for monitoring critical folders.

Can I check folder sizes for hidden folders?

Yes, you can use the appropriate flags or options to include hidden folders in the size calculation.

Are there graphical tools for checking folder size?

Yes, there are various graphical tools available for users who prefer a visual representation of folder sizes, such as WinDirStat, TreeSize, and Disk Inventory X.

How to check folder size in Linux?

You can use the “du” (disk usage) command in Linux to check the size of a folder. For example, “du -sh folder_name” will display the folder size in a human-readable format.

How to check folder size in command?

To check the folder size in a command prompt or terminal, you can use the “dir” command in Windows or the “du” command in Linux/macOS, as mentioned above, depending on your operating system.


Checking folder size in command-line interfaces is a valuable skill for efficient storage management. By following the steps outlined in this guide, you can gain a deeper understanding of your storage space, optimize system performance, and ensure your computer operates smoothly.

Leave a comment