Conditionally executes a command. Available elementary tests:
exist <filename>
<string>==<string>
<expression1> equ <expression2>
-- equals<expression1> neq <expression2>
-- not equal<expression1> lss <expression2>
-- less than<expression1> leq <expression2>
-- less than or equal<expression1> gtr <expression2>
-- greater than<expression1> geq <expression2>
-- greater than or equaldefined <variable>
errorlevel <number>
cmdextversion <number>
To each elementary test, "not" can be applied. Apparently there are no operators like AND, OR, etc. to combine elementary tests.
The /I
switch makes the ==
and equ
comparisons ignore case.
An example:
if not exist %targetpath% (
echo Target path not found.
exit /b
)
Examples:
if not 1 equ 0 echo Not equal
if 1 equ 0 echo A & echo B
Does nothing; both echo commands are subject to the condition.
if not 1 equ 0 goto :mylabel