Batch 脚本中使用 IF EXIST 语句时,总是提示
The syntax of the command is incorrect.
原始 bat 脚本如下:
ECHO OFF
SET project="C:\Temp" IF EXIST %project%\build.log(
ECHO File found
)ELSE(
ECHO File missing
)
原因是遗漏了起关键作用的 空格。
ECHO OFF
SET project="C:\Temp" REM There must be a space placed before the parenthesis(
IF EXIST %project%\build.log (
REM 圆括号 ( 前要留有一个空格。
ECHO File found
) ELSE (
ECHO File missing
)