Can we set two variable (Partition and Removable) containing Drive Letters in order of Volume Number with status 'Healthy' ?
Partition : C H F G D I J ->> MostFreePart : I
Removable : K E L ->> MostFreeRem : E
Then we can get %MostFreePartMB% out of %Partition% and %MostFreeRemMB% out of %Removable% ?
Why not?
The issue might be the volume(s) which is/are "Healthy" AND "NTFS" BUT do not have a drive letter assigned.
I guess we can use "fixed size fields" instead of tokens and delims.
@ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET Removable= SET Partition= FOR /F "tokens=*" %%A IN ('ECHO LIST VOLUME ^| DISKPART ^|FIND "Healthy" ^|FIND "NTFS"') DO CALL :parse_volumes %%A SET Removable SET Partition GOTO :EOF :parse_volumes SET Line=%* IF NOT "%Line:~13,1%"==" " SET %Line:~37,9%=!%Line:~37,9%! %Line:~13,1%: GOTO :EOF
Wonko