1

With my code I am getting the folder size in GB with no decimal places. But I need it in GB with having a decimal point and 2 decimal places.

@echo off
for /F "tokens=*" %%a IN ('"dir C:\Users\rinni.abraham\Desktop\fresh %1 /s /-c | find "bytes" | find /v "free""') do set summaryout=%%a
for /f "tokens=1,2 delims=)" %%a in ("%summaryout%") do set filesout=%%a&set sizeout=%%b
set sizeout=%sizeout:bytes=%
set sizeout=%sizeout: =%
echo Size is: %sizeout%
pause
set /a  sizeout=%sizeout%/1049
set /a  sizeout=%sizeout%/1024

This is my output:

Size is: 2gb

I would like the output as:

Size is: 2.03 gb
Mofi
  • 46,139
  • 17
  • 80
  • 143
rins
  • 7
  • 5
  • Take a look at this ==> http://stackoverflow.com/questions/37178953/folder-list-and-its-sizes/37181665#37181665 – Hackoo May 18 '16 at 07:39
  • Possible duplicate of [Get size of a directory in 'MB' using batch file](http://stackoverflow.com/questions/36301198/get-size-of-a-directory-in-mb-using-batch-file) – aschipfl May 18 '16 at 08:29
  • Take a look at this: [Get size of a directory in 'MB' using batch file](http://stackoverflow.com/a/36318398); this constitutes a pure [tag:batch-file] solution; for decimal places, append zeros to the divident (`00` for 2 dec. pl.), adapt the divisor (e. g., `1048576` for MiB) and insert a dec. pt. afterwards by sub-string expansion (e. g., `VAR` contains calc. result: `%VAR:~,-2%.%VAR:~-2%` holds result incl. dec. pt.)... – aschipfl May 20 '16 at 08:20

0 Answers0