[RESOLVED] Simple Batch file question
I'm trying to do a number comparison in a ms-dos batch file. I have the following code
set /a lastmonth_=%monthnr_%-1
echo %lastmonth_%
if %lastmonth_% < 10 set %lastmonth_% = 0%lastmonth_%
echo %lastmonth_%
the "< 10" isn't working - says something about < is unexpected.
How do you do number comparisons in MS DOS batch files?
Thanks.
Re: Simple Batch file question
You have to use abbreviations.
LSS is less than
LEQ is less than or equal to
GTR is greater than
GEQ is greater than or equal to
Same for equals (EQU) and not equals (NEQ). If you just use a = then it automatically stores to the variable, even in an if statement.