Skip to main content

Performs conditional processing in batch scripts.

:: To execute the specified commands if the condition is true:
if <condition> (<echo Condition is true>)

:: To execute the specified commands if the condition is false:
if not <condition> (<echo Condition is true>)

:: To execute the first specified commands if the condition is true otherwise execute the second specified commands:
if <condition> (<echo Condition is true>) else (<echo Condition is false>)

:: To check whether '%errorlevel%' is greater than or equal to the specified exit code:
if errorlevel <exit_code> (<echo Condition is true>)

:: To check whether two strings are equal:
if %<variable>% == <string> (<echo Condition is true>)

:: To check whether two strings are equal without respecting letter case:
if /i %<variable>% == <string> (<echo Condition is true>)

:: To check whether a file exist:
if exist <path/to/file> (<echo Condition is true>)