Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > To get amount of free space in MB using batch file programming windows xp

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

Forum Windows XP : Windows XP General Discussion - To get amount of free space in MB using batch file programming windows xp

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

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 :diskcheck !freeval!
)
endlocal
goto :eof

:diskcheck
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

Sponsored Links
Register or log in to remove.

Quote :

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



Comparison chart you will need.

http://img195.imageshack.us/img195/3647/hangoverq.gif

------------------------------ "To better understand why you need a personal computer, let's take a look at the pathetic mess you call your life."
Reply to badge
Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > To get amount of free space in MB using batch file programming windows xp
Go to:

There are 719 identified and unidentified users. To see the list of identified users, Click here.

Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them