Batch file not working: spaces in the path

set RF_PROPERTIES="%ARCOT_HOME%\conf"
dir %RF_PROPERTIES%
if not exist %RF_PROPERTIES%
goto NO_RF_PROPERTIES

The variable ARCOT_HOME above has spaces. The dir command works and lists the files, but the if command does not work: "The command syntax is incorrect." Is there any way to make it work?

+3
source share
2 answers

Try this:

set RF_PROPERTIES=%ARCOT_HOME%\conf
dir "%RF_PROPERTIES%"
if not exist "%RF_PROPERTIES%" goto NO_RF_PROPERTIES
+5
source
if not exist "%RF_PROPERTIES%" GOTO NO_RF_PROPERTIES
GOTO OK

:NO_RF_PROPERTIES

GOTO END

:OK

GOTO END

:END
+3
source

Source: https://habr.com/ru/post/1790928/


All Articles