Walking Corpse
Walking Corpse

Reputation: 83

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?

Upvotes: 3

Views: 6043

Answers (2)

rene
rene

Reputation: 42483

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

:NO_RF_PROPERTIES

GOTO END

:OK

GOTO END

:END

Upvotes: 3

David Heffernan
David Heffernan

Reputation: 613262

Try it this way round:

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

Upvotes: 5

Related Questions