if / else
Try it yourself →Runs a command based on a condition.
Syntax
if condition (...) else (...)
Description
Comparison: == (equal), equ gtr lss (numeric). if exist checks if a file exists, if errorlevel checks error codes.
Example
@echo off set /a x=7 if %x% gtr 5 (echo greater) else (echo smaller)
Expected output
greater
When to use?
Flow branching.