Reputation: 743
I try to use with "else" command but I get the foloowing error:
'else' is not recognized as an internal or external command, operable program or batch file.
My code is:
if "zz"=="TRUE" (
copy /a zz + /a ee=/a zz
)
else (
copy /a e + /a %TMP%=/a e
)
What the problem?
Upvotes: 47
Views: 62900
Reputation: 37222
The else
needs to be on the same "line" (a) as the if
. Remove the new-line before the else
like so:
if "zz"=="TRUE" (
copy /a zz + /a ee=/a zz
) else (
copy /a e + /a %TMP%=/a e
)
Please also note that "zz"=="TRUE"
will never evaluate to true
- I suspect you meant "%zz%"=="TRUE"
?
(a): This isn't always a good description, though it's what the Microsoft documents use. Same command may have been better, and putting )
and else
on a different line breaks it into two commands.
Upvotes: 105