Free disk space script

@echo off
rem set SPACE_LIMIT=200
set /p SPACE_LIMIT=Limit:

for /f “tokens=3” %%i in (‘”dir c: /-c | find /i “bytes free””‘) do set TSPACE=%%i
set FREE_SPACE=%TSPACE:~0,-6%
if %FREE_SPACE% GTR %SPACE_LIMIT% (
echo %FREE_SPACE% ^> %SPACE_LIMIT%
) else (
echo %FREE_SPACE% ^< %SPACE_LIMIT%
)

Script drops last six digits from ‘total bytes free’ line of dir command because of cmd.exe 32-bit integer limitation so a comparision is done using megabytes.