in Education by
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. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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 :-)

Related questions

0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I'm trying to run PHP from the command line under Windows XP. That works, except for the fact ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    If I issue the find command as follows: find . -name *.ear It prints out: ./dir1/dir2/earFile1. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 26, 2022 in Education by JackTerrance
0 votes
    I would like to get the list of files exist in folder and subfolder with full path.Don't want any ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I'm building an application with C# code. How do I get only the date value from a DateTimePicker ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    A windows which menu contains the sizing option which enable you to change the window size easily Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    I want to get the size of an http:/.../file before I download it. The file can be a webpage ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    Which module in the python standard library parses options received from the command line? a) getarg b) getopt c) main d) os...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Which module in the python standard library parses options received from the command line? a) getarg b) getopt c) main d) os...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Have been needing to write some code that recognises (and captures) when there's incoming/outgoing smb ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I'm using this script for building application from command line: #!/bin/bash TARGET="signtest" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I've got two different apps that I am hosting (well the second one is about to go up) on Amazon EC2. ... path ; ec2-describe-instances Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
...