IF
[/?]
[/I]
expression
command
/?/IIf expression evaluates true, the IF command executes command. The result obtained from executing (or attempting to execute) command is returned as the result of the IF command.
If expression evaluates false, no command is executed and the IF command returns as its result the result of the previous command to execute (thereby allowing multiple IF ERRORLEVEL tests to be used in succession).
command must a basic command, and cannot be a pipeline or a sequence of commands. It is not passed through environment variable expansion or redirection processing a second time before being executed. Any redirection, pipeline, or other metacharacters that appear in command, as a result of the environment variable expansion and other parsing of the original command line, are not given any special treatment.
To execute multiple commands in an IF command, use CALL or GOSUB for command in order to execute a separate command script or a subroutine.
expression must be one of the following:
All comparisons are case-sensitive.
An easy way to remember the difference between "EXIST" and "EXISTS" is that the former is the plural form of the verb and can apply to more than one file or directory, whereas the latter is the singular form of the verb and applies to just one file or directory. "EXISTS" is useful for testing for the specific existence of files and directories whose names contain basic search wildcard metacharacters.
Redirection takes place only once. Because of the way that the command interpreter works, redirection takes place before the IF command is invoked. This means that redirection applies whether expression evaluates true or false.
CALL EXTPROC FOR GOTO GOSUB RETURN CANCEL QUIT EXIT