Chapter 6 / Command Reference
IF
IF [NOT] condition command
Internal
. i
U
I i
I I
'--'
: )
U
Allows conditional execution of commands
in
batch file process-
ing. When
the
condition is true,
the
command is executed. When
it
is false,
the
command is ignored.
Parameters
NOT changes the
IF
command
so
that
the
command executes
only when
the
condition is false.
condition is one of
the
following:
ERRORLEVEL number indicates
that
the command is to
execute only
if
the
program previously executed by
COM-
MAND
has
an
exit
code
of number or higher.
stringl = = string2 indicates
that
the command is to
exe-
cute only
if
stringl and string2
are
identical after parame-
ter
substitution. Strings may not have embedded
separators.
EXIST pathname indicates
that
the
command is to execute
only
if
the
file specified by pathname exists.
Notes
and
Suggestions
• Use
IF
with
the
GOTO command to direct execution to partic-
ular
subroutines when particular conditions exist. (See
the
GOTO command.)
114
. I
! I
L.J
i I
t--1
, I
'---.!
I •
: I
'---'
I
L....1
i
e-J
I
I I
L...J
: I
U
I
.--1
I I
, ,
~