该命令的语法是不正确的bat文件

时间:2017-06-21 09:26:18

标签: batch-file

我有以下代码:

set originalDiractory = %1
set tableauReposetory = %2
set imageName = %3
set isFemale = %4

IF %isFemale% ==1(
copy /y "%originalDiractory%\User_Gender_Files\Female.png"  "%tableauReposetory%\%imageName%.png"
)
IF %isFemale% ==0(
copy /y "%originalDiractory%\User_Gender_Files\Male.png"  "%tableauReposetory%\%imageName%.png"
)

当我从CMD运行时,我收到以下错误:

C:\<path>>set isFemale = "0"
The syntax of the command is incorrect.
C:\<path>>IF 0 ==1(

我错过了什么?怎么了?

我在源周围添加了Apostrophes,目标仍然不起作用

1 个答案:

答案 0 :(得分:0)

您可以像这样调整所提供代码的结构:

@Echo Off
If "%~4" NEq "1" (If "%~4" NEq "0" (Exit/B) Else Set "srcImg=M"
) Else Set "srcImg=Fem"
Copy /Y "%~1\User_Gender_Files\%srcImg%ale.png" "%~2\%~3.png" 2>Nul

此代码和您的一样,假定输入参数对于正在运行的Copy命令是满意的