Sign in with
Sign up | Sign in

To get amount of free space in MB using batch file programming windows xp

Last response: in Windows XP
Share

i need to get amount of disk free space in MB and compare if it is less than 40 MB,

The comparison leading to wrong result

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=3 delims= " %%A in ('dir /-c D:^|find "Dir(s)"') do (
set freeval=%%A
call :D iskcheck !freeval!
)
endlocal
goto :eof

:D iskcheck
set space=%1
REM 1 MB=1048575 Bytes, 40 MB=4195040 Bytes
set limit=4195040
set /a sub=%space%-%limit%
echo %sub%
echo %1 bytes
echo %space% bytes
echo %limit% bytes
echo Drive is D: and its freespace is %space% Bytes
if %space% GTR %limit% (echo disc space is high) else (echo Disc space is low.Cannot install the new software version.)
goto :eof
Ask the community
!