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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You can just add up sizes recursively (the following is a batch file):
However, this has several problems because
cmdis 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:
or shorter:
If you want it prettier:
You can use this directly from
cmd: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 🙂