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
Try:
SET FOLDERSIZE=0
FOR /F "tokens=3" %A IN ('DIR "C:\Program Files" /a /-c /s ^| FINDSTR /C:" bytes" ^| FINDSTR /V /C:" bytes free"') DO SET FOLDERSIZE=%A
Change C:\Program Files to whatever folder you want and change %A to %%A if using in a batch file
It returns the size of the whole folder, including subfolders and hidden and system files, and works with folders over 2GB
It does write to the screen, so you'll have to use an interim file if you don't want that.