Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

du Command for Windows: How to Check Folder Sizes

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The du command is a Unix/Linux tool for estimating disk usage, and it does not exist natively in Windows. To get the same result on Windows, you can use PowerShell's Get-ChildItem with Measure-Object, install the Windows Sysinternals du utility, or use the built-in dir command with the /s switch for a quick total. The simplest built-in method is a one-line PowerShell command that sums file lengths in a folder.

What You'll Need

  • A Windows 10 or Windows 11 PC (the steps also work on Windows 8.1 and 7 with PowerShell 5.1).
  • Access to PowerShell or Command Prompt. No administrator rights are required for reading folder sizes, but you may need them for system folders.
  • Optional: the Sysinternals du utility from Microsoft's official download page if you want a true du command.

Step-by-Step

  1. Open PowerShell. Press Win + X and choose Windows PowerShell or Terminal. On Windows 11, Terminal opens PowerShell by default. You can also search for PowerShell in the Start menu.
  2. Navigate to the folder you want to measure. Use cd followed by the path, for example: cd C:\Users\YourName\Documents. If the path contains spaces, wrap it in quotes: cd "C:\Users\Your Name\Documents".
  3. Run the folder-size command. Type the following and press Enter:
    Get-ChildItem -Recurse -File | Measure-Object -Property Length -Sum
    This lists every file in the current folder and all subfolders, then sums their sizes in bytes. The output shows Count (number of files) and Sum (total bytes).
  4. Convert bytes to a readable unit. Divide the Sum value by 1,048,576 for megabytes or by 1,073,741,824 for gigabytes. For a quicker readable output, use:
  5. Measure a folder without changing directory. Use the -Path parameter:
    Get-ChildItem -Path "C:\Users\YourName\Downloads" -Recurse -File | Measure-Object -Property Length -Sum
  6. See per-subfolder sizes. To list the size of each immediate subfolder, run:
    Get-ChildItem -Directory | ForEach-Object { $size = (Get-ChildItem $_.FullName -Recurse -File | Measure-Object -Property Length -Sum).Sum; [PSCustomObject]@{Folder=$_.Name; SizeMB=[math]::Round($size/1MB,2)} }
    This prints a table of folder names and their sizes in megabytes.
  7. Optional: use the Sysinternals du tool. Download du from Microsoft's Sysinternals page (official Microsoft source). Extract du.exe to a folder in your PATH, or run it from its folder. Then in Command Prompt or PowerShell, run:
    du -sh C:\Users\YourName\Documents
    The -s flag gives a summary, and -h makes the output human-readable. Run du -? to see all options.
  8. Optional: use Command Prompt's dir. In Command Prompt, run:
    dir /s /a "C:\Users\YourName\Documents"
    The last line shows the total number of files and total bytes. This is less flexible than PowerShell but requires no extra tools.

Common Mistakes

  • Forgetting -File. Without it, Get-ChildItem -Recurse includes folders, and Measure-Object -Property Length may error or return zero because folders do not have a Length property.
  • Running from the wrong directory. If you do not cd into the target folder and do not use -Path, you will measure whatever folder PowerShell opened in, often your user profile.
  • Expecting du to work out of the box. Typing du in a fresh Windows install returns "not recognized." You must install Sysinternals du or use PowerShell.
  • Ignoring hidden and system files. By default, Get-ChildItem skips hidden items. Add -Force to include them: Get-ChildItem -Recurse -File -Force | Measure-Object -Property Length -Sum.
  • Using dir /s on huge drives without patience. It can take a long time and may hit access-denied errors on protected folders; run it on a specific folder rather than the whole drive.

Tips

  • Use -ErrorAction SilentlyContinue to skip folders you cannot access without stopping the whole command: Get-ChildItem -Recurse -File -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum.
  • For a quick visual overview, Windows Settings > System > Storage shows per-category usage, and File Explorer's folder Properties dialog shows a folder's size on disk, though it can be slow on large trees.
  • PowerShell 7 (installed separately) handles very large folder trees faster than Windows PowerShell 5.1 in many cases.
  • If you only need the total for one folder, dir /s in Command Prompt is the fastest no-install option.

Troubleshooting

  • "du is not recognized": You have not installed Sysinternals du or it is not in your PATH. Either add its folder to PATH or call it with the full path, e.g. C:\Tools\du.exe -sh C:\Folder.
  • Command returns zero or a blank Sum: Check that you included -File and that the path exists. If the folder is empty, the sum is null; that is expected.
  • Access denied errors: Run PowerShell as administrator for protected folders, or add -ErrorAction SilentlyContinue to skip them. Note that skipped files are not counted.
  • Very slow results on large drives: Measure one subfolder at a time, or use the Sysinternals du tool, which is optimized for this task.
  • Output in bytes is hard to read: Use the Select-Object expression shown in step 4 to convert to MB, or pipe to Format-List for a clearer layout.

Frequently Asked Questions

Is there a built-in du command in Windows?

No. Windows does not ship a command called du. The closest built-in options are PowerShell's Get-ChildItem with Measure-Object and Command Prompt's dir /s.

Can I use du in Command Prompt after installing Sysinternals?

Yes. Once du.exe is in a folder listed in your PATH, you can run du -sh C:\Folder from either Command Prompt or PowerShell.

How do I get folder sizes in GB instead of bytes?

Divide the Sum by 1GB in PowerShell: [math]::Round($_.Sum/1GB,2). The example in step 4 shows the full command.

Why does PowerShell skip some files?

By default it hides hidden and system files, and it may skip files you lack permission to read. Add -Force to include hidden items and run as administrator for protected locations.

Does du work on Windows Subsystem for Linux?

Yes. If you have WSL installed, you can run Linux du inside the WSL environment, but it measures files as seen from Linux, which may differ slightly from Windows reporting.

What is the fastest way to check a single folder's size?

For a quick total, open Command Prompt and run dir /s "C:\Folder". For scripted or repeated use, the PowerShell one-liner is more flexible.