Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch file not working: Spaces in path

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?

like image 702
Hugh Darling Avatar asked Nov 18 '25 00:11

Hugh Darling


2 Answers

Try it this way round:

set RF_PROPERTIES=%ARCOT_HOME%\conf
dir "%RF_PROPERTIES%"
if not exist "%RF_PROPERTIES%" goto NO_RF_PROPERTIES
like image 87
David Heffernan Avatar answered Nov 20 '25 16:11

David Heffernan


if not exist "%RF_PROPERTIES%" GOTO NO_RF_PROPERTIES
GOTO OK

:NO_RF_PROPERTIES

GOTO END

:OK

GOTO END

:END
like image 41
rene Avatar answered Nov 20 '25 18:11

rene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!