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 following script can be used to fetch and accumulate the size of each file under a given folder.
The folder path %folder% can be given as an argument to this script (%1).
Ultimately, the results is held in the parameter %filesize%
@echo off
SET count=1
SET foldersize=0
FOR /f "tokens=*" %%F IN ('dir /s/b %folder%') DO (call :calcAccSize "%%F")
echo %filesize%
GOTO :eof
:calcAccSize
REM echo %count%:%1
REM set /a count+=1
set /a foldersize+=%~z1
GOTO :eof
Note: The method calcAccSize can also print the content of the folder (commented in the example above)