[SOLVED] Get TRUE HDD data as opposed to CAPACITY data.
Posted: 06 Nov 2019 07:03
Good afternoon,
After something I was doing yesterday and Steffen managed to sort out for me, I noticed that what I did a few days ago was actually incorrect. It is getting the true size of the HDD as opposed to the capacity.
This is the code that works but gives the capacity rather than the true size because I need to get the result divided by /1024*1000/1024/1024 according to my research and to TWO decimal places.
Now I have tried this amongst many others . . .
. . . and this . . .
I will not list them.
Thanks in advance.
After something I was doing yesterday and Steffen managed to sort out for me, I noticed that what I did a few days ago was actually incorrect. It is getting the true size of the HDD as opposed to the capacity.
This is the code that works but gives the capacity rather than the true size because I need to get the result divided by /1024*1000/1024/1024 according to my research and to TWO decimal places.
Code: Select all
Set "Volume=C:"
For /f "Tokens=1*Delims=:" %%i In ('fsutil Volume DiskFree %SystemDrive%') Do (
Set "PC_Volume=!PC_DiskTotal!"
Set "PC_DiskTotal=!PC_DiskFree!"
Set "PC_DiskFree=%%j"
)
Set /a PC_DiskUsed=%PC_DiskTotal:~0,-9% - %PC_DiskFree:~0,-9%
echo %systemdrive% Partition Size: %PC_DiskTotal:~0,-9% GB
echo %systemdrive% Partition Used: %PC_DiskUsed% GB
echo %systemdrive% Partition Free: %PC_DiskFree:~0,-9% GB
Code: Select all
SetLocal EnableDelayedExpansion
:: PC HDD Partition Size
Set "Volume=C:"
For /f "Tokens=1*Delims=:" %%i In ('fsutil Volume DiskFree %SystemDrive%') Do (
Set "PC_Volume=!PC_DiskTotal!"
Set "PC_DiskTotal=!PC_DiskFree!"
Set "PC_DiskFree=%%j"
)
Set /a PC_DiskUsed=%PC_DiskTotal:~0,-9/1024*1000/1024/1024% - %PC_DiskFree:~0,-9/1024*1000/1024/1024%
echo %systemdrive% Partition Size: %PC_DiskTotal:~0,-9/1024*1000/1024/1024%
echo %systemdrive% Partition Used: %PC_DiskUsed/1024*1000/1024/1024%
echo %systemdrive% Partition Free: %PC_DiskFree:~0,-9/1024*1000/1024/1024%
Code: Select all
SetLocal EnableDelayedExpansion
Set "Volume=C:"
For /f "Tokens=2 Delims=:" %%a In ('fsutil Volume DiskFree C: ^| Find /i "avail free"') Do Set bytes=%%a
set /a Calc_True=%bytes:~0,-3%/1024*1000/1024/1024
For /f "Tokens=1*Delims=:" %%i In ('fsutil Volume DiskFree %SystemDrive%') Do (
set /a Calc_True="/1024*1000/1024/1024"
Set /a "PC_Volume=PC_Volume / %Calc_True%"
Set /a "PC_DiskTotal=PC_DiskTotal / %Calc_True%"
Set /a "PC_DiskFree=PC_DiskFree / %Calc_True%"
Set "PC_Volume=!PC_DiskTotal!"
Set "PC_DiskTotal=!PC_DiskFree!"
Set "PC_DiskFree=%%j"
)
Set /a "PC_DiskFree=PC_DiskFree / %Calc_True%"
Set /PC_DiskUsed=%PC_DiskTotal:~0,-9% - %PC_DiskFree:~0,-9%
echo %systemdrive% Partition Size: %PC_DiskTotal%
echo %systemdrive% Partition Used: %PC_DiskUsed%
echo %systemdrive% Partition Free: %PC_DiskFree:~0,-9%
Thanks in advance.