I am trying to get the freespace on a hard drive, and then compare it to a value, (to make sure we are not running out of disk space).
I can get it all to work except the final comparison. I am assuming it is because of the format that the free space value is being stored in, but I am not sure how to adjust my code.
My Code:
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='W:'" get FreeSpace /format:value`) do set FreeSpace=%%x
If %FreeSpace% LEQ 1000000000 (
echo %FreeSpace% is Less Than 1G of free space
pause
) else (
echo %FreeSpace% is Greater than 1G of free space
pause
)
I want to know if the freespace is greater or less than 1GB. However, it always tells me that it is lower, no matter what value I use for comparison.