windows 批处理文件不起作用:路径中有空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4944469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:08:33 来源:igfitidea点击:
Batch file not working: Spaces in path
提问by Hugh Darling
set RF_PROPERTIES="%ARCOT_HOME%\conf"
dir %RF_PROPERTIES%
if not exist %RF_PROPERTIES%
goto NO_RF_PROPERTIES
The ARCOT_HOME variable above has spaces. The dir command works and lists the files, but the if command fails with "The syntax of the command is incorrect.". Is there a way to make it work?
上面的 ARCOT_HOME 变量有空格。dir 命令有效并列出文件,但 if 命令失败并显示“命令的语法不正确。”。有没有办法让它工作?
回答by David Heffernan
Try it this way round:
试试这个方法:
set RF_PROPERTIES=%ARCOT_HOME%\conf
dir "%RF_PROPERTIES%"
if not exist "%RF_PROPERTIES%" goto NO_RF_PROPERTIES
回答by rene
if not exist "%RF_PROPERTIES%" GOTO NO_RF_PROPERTIES
GOTO OK
:NO_RF_PROPERTIES
GOTO END
:OK
GOTO END
:END