@isdir
expands always to FALSE
or TRUE
in upper case.
if @isdir equ FALSE
is a case-sensitive string comparison of FALSE
or TRUE
with FALSE
using integer comparison operator EQU
falling back to a string comparison because of neither string FALSE
nor string TRUE
can be converted successfully to an integer, see Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files for details.
For a case-insensitive string comparison use in the command line:
if /I @isdir == FALSE
And if @isdir==FALSE
is better than if @isdir equ FALSE
, but the behavior is the same.
Best is to use if @isdir == FALSE
as this is 100% correct syntax.
IF command syntax for string comparison on equality:
IF FirstStringToCompare == SecondStringToCompare Command
or for strings containing a space or &()[]{}<>|^=;!'+,`~
IF "first string to compare" == "second string to compare" "command to execute"
The command is IF separated from first argument string with a space character which is either the string FALSE
or the string TRUE
in this case. The first string to compare is separated from second argument with a space with is the equal operator ==
. After one more space the third argument is specified which is the second string to compare. The last command separated again with a space from third argument is the command to execute on string equality.
The spaces around operator ==
are often omitted although actually required to separate the first from second and second from third argument. But Windows command interpreter recognizes the missing spaces around operator ==
and add them automatically as it can be seen on writing into a batch file just the two lines
if FALSE==FALSE echo It is FALSE.
if TRUE == FALSE echo It is FALSE.
and run this batch file in a command prompt window resulting in output:
if FALSE == FALSE echo It is FALSE.
It is FALSE.
if TRUE == FALSE echo It is FALSE.
The command lines really executed after preprocessing by Windows command interpreter have one space between each argument.
The help for command IF output on running in a command prompt window if /?
shows the string comparison syntax as:
IF [NOT] string1==string2 command
So it can be supposed that the space left and right of ==
are not really required as long as the strings to compare do not contain itself an equal sign in which case it is necessary to enclose both strings to compare in double quotes.