I have problem for comparing high numbers of the PC disks.
Script:
for /f "tokens=* delims== skip=1" %%x in ('"wmic.exe logicaldisk where DriveType=3 get DeviceID,FreeSpace,Size"') do (
for /f "tokens=1-3" %%a in ("%%x") do (
set "DiskID=%%a" & set "DiskFree=%%b"
if !DiskFree! gtr !DiskFreeFinal! Set "DiskIDFinal=!DiskID!" && set "DiskFreeFinal=!DiskFree!"
)
)
echo Biggest free space is on drive: %DiskIDFinal% (%DiskFreeFinal%)
Output is bad size comparing not real.
You could left-zero-pad the numbers to compare to the same width and do string comparison then:
Alternatively, you could split the numbers into two parts and compare them individually:
Your batch reworked to do string based comparisons for large numbers (up to 88817 PetaByte)
Sample output (including the REMed out line):
An accompanying
PowerShell
answer, (despite the lack of an appropriate tag), for informational and comparison purposes.