我有以下代码:
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,目标仍然不起作用
答案 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
命令是满意的