Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8656043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:10:56+00:00 2026-06-12T15:10:56+00:00

Is it possible in Windows to get a folder’s size from the command line

  • 0

Is it possible in Windows to get a folder’s size from the command line without using any 3rd party tool?

I want the same result as you would get when right clicking the folder in the windows explorer → properties.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:10:57+00:00Added an answer on June 12, 2026 at 3:10 pm

    You can just add up sizes recursively (the following is a batch file):

    @echo off
    set size=0
    for /r %%x in (folder\*) do set /a size+=%%~zx
    echo %size% Bytes
    

    However, this has several problems because cmd is limited to 32-bit signed integer arithmetic. So it will get sizes above 2 GiB wrong1. Furthermore it will likely count symlinks and junctions multiple times so it’s at best an upper bound, not the true size (you’ll have that problem with any tool, though).

    An alternative is PowerShell:

    Get-ChildItem -Recurse | Measure-Object -Sum Length
    

    or shorter:

    ls -r | measure -sum Length
    

    If you want it prettier:

    switch((ls -r|measure -sum Length).Sum) {
      {$_ -gt 1GB} {
        '{0:0.0} GiB' -f ($_/1GB)
        break
      }
      {$_ -gt 1MB} {
        '{0:0.0} MiB' -f ($_/1MB)
        break
      }
      {$_ -gt 1KB} {
        '{0:0.0} KiB' -f ($_/1KB)
        break
      }
      default { "$_ bytes" }
    }
    

    You can use this directly from cmd:

    powershell -noprofile -command "ls -r|measure -sum Length"
    

    1 I do have a partially-finished bignum library in batch files somewhere which at least gets arbitrary-precision integer addition right. I should really release it, I guess 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to get the bios information of windows 7 using java, the
I'm running a node script from the command line on Windows and am trying
Possible Duplicate: How to get folder path from file path with CMD I have
Is it possible to get Windows Server 2003 hosted with options similar to Linux
Possible Duplicate: C# - How to get Program Files (x86) on Windows Vista 64
Possible Duplicate: How to get the sort order in Delphi as in Windows Explorer?
Is it possible to get shutdown reason in Windows Server 2008 immediately after user
Possible Duplicate: In java under Windows, how do I find a redirected Desktop folder?
Is it possible to get the name of the last created folder in a
How to get from C/C++ extension source code to a pyd file for windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.