what is the actual free space on windows C drive

6.5k views Asked by At

I have a batch script in which I need to make sure I have at least 3 GB of available free space.

To get the available free space via command line you type:

fsutil volume diskfree C: | find /i "avail free"
Total # of avail free bytes  : 872762081280

This is the number of bytes, which is similarly displayed when you 'right click' -> 'property' on your C drive.

However, when I 'right click' -> 'property' on my C drive, next to the 872,762,081,280 it shows me a GB value of only 812GB of available free space. This is drastically different from the byte value of 872762081280.

I thought this might be due to the 1024bytes = 1kb windows conversion. However, this conversion will show i have 852,306,720kb available (or 852GB) which is still not close to the 812GB which the 'Local Disk (C:) Properties' window is showing me.

Does anyone know the math which windows is using which converts 872,762,081,280 bytes down to 812GB?

5

There are 5 answers

1
Glenn Teitelbaum On BEST ANSWER

There are 1024 bytes in a KB, 1024 KB in a MB, 1024 MB in a GB so:

872762081280 bytes           1 KB              1 MB          1 GB
                       x    -------       x   ------   x    -----     = 812 GB
                            1024 bytes        1024 KB       1024 MB

Note the use of KB, MB, and GB follow the JEDEC memory standards nomenclature

Under IEC 60027 notation these would be denoted by KiB, MiB and GiB

There is much confusion over this since they both use multiples of 1024, but the Decimal nomenclature uses the same KB, MB and GB but with multiples of 1000, as used by some disk manufacturers

0
Stephan On
@echo off
setlocal
set drive=C
set free=?

rem Note: WMIC will output unicode text
wmic logicaldisk where (caption = "%drive%:") get freespace>"%temp%\free.tmp"
for /f %%A in ('type "%temp%\free.tmp"') do (set free=%%A)

SET free=%free:~0,7%
SET /a "free=(((free/1024)*1000)/1024*100)/1024"
::SET free=%free:~7,5%
echo Free space: %free% Gb
rem if exist "%temp%\free.tmp" del "%temp%\free.tmp"

pause
0
Aacini On

You may get the number of available space in GB this way:

for /F "tokens=2 delims=:" %%a in ('fsutil volume diskfree C: ^| find /i "avail free"') do set bytes=%%a
set /A GB=%bytes:~0,-3%/1024*1000/1024/1024
echo GB=%GB%
2
Mark Ransom On
872762081280 / 1024 / 1024 / 1024 = 812
0
cheefyboy On

It's easiest is to remember KB, MB, and GB are based on powers of 2.

    1 KB = 2^10 (2 to the 10th power or 1,024 bytes)
    1 MB = 2^20 (2 to the 20th power or 1,048,576 bytes)
    1 GB = 2^30 (2 to the 30th power or 1,073,741,824 bytes)

All you would need to do is divide your large number by 2^30 to get your number of GB's.

    Your value: 872,762,081,280 bytes
    KB............  MB..........  GB.........
       852306720.0      832330.8      812.823