C
C#2y ago
Ted Bunny

Batch script issue with spaces in strings

The script:
REM This script copies your project's outputs into the game folders. Then it runs the game executable.
ECHO "======= POST-BUILD"

ECHO " --- Defining directories"
SET destinationBepinex="C:\Program Files (x86)\Steam\steamapps\common\Streets of Rogue\BepInEx\"
SET destinationPlugins="%destinationBepinex%plugins\"
SET originPlugins=%cd%\

ECHO " --- Defining series"
SET exportsPlugins=CCU.dll

ECHO " --- Copying files"
FOR %%a IN (%exportsPlugins%) DO (XCOPY /s /y "%originPlugins%%%~a" %destinationPlugins%)

ECHO " --- Running game"
SET executable="C:\Program Files (x86)\Steam\steamapps\common\Streets of Rogue\StreetsOfRogue.exe"
CALL "" "%executable%"
REM This script copies your project's outputs into the game folders. Then it runs the game executable.
ECHO "======= POST-BUILD"

ECHO " --- Defining directories"
SET destinationBepinex="C:\Program Files (x86)\Steam\steamapps\common\Streets of Rogue\BepInEx\"
SET destinationPlugins="%destinationBepinex%plugins\"
SET originPlugins=%cd%\

ECHO " --- Defining series"
SET exportsPlugins=CCU.dll

ECHO " --- Copying files"
FOR %%a IN (%exportsPlugins%) DO (XCOPY /s /y "%originPlugins%%%~a" %destinationPlugins%)

ECHO " --- Running game"
SET executable="C:\Program Files (x86)\Steam\steamapps\common\Streets of Rogue\StreetsOfRogue.exe"
CALL "" "%executable%"
Output:
1> "======= POST-BUILD"
1> " --- Defining directories"
1> " --- Defining series"
1> " --- Copying files"
1> \Steam\steamapps\common\Streets was unexpected at this time.
1> "======= POST-BUILD"
1> " --- Defining directories"
1> " --- Defining series"
1> " --- Copying files"
1> \Steam\steamapps\common\Streets was unexpected at this time.
5 Replies
Ted Bunny
Ted BunnyOP2y ago
So, I encapsulated the original string definition in quotes. I thought it would avoid it parsing spaces when I concatenate it with the %%a series member. I've tried encapsulating that concatentation in quotes, tried it without, tried removing the tilde, all have the same effect. Any ideas?
phaseshift
phaseshift2y ago
you might not want quotes in SET executable="C:\Program Files (x86)\Steam\steamapps\common\Streets of Rogue\StreetsOfRogue.exe"
Ted Bunny
Ted BunnyOP2y ago
But the filepath has spaces in it. Wouldn't that cause it to parse the spaces outside of the string?
phaseshift
phaseshift2y ago
when you use it, put it in quotes but you have quotes in the variable, then also wrapping in quotes again
Ted Bunny
Ted BunnyOP2y ago
Oh nice, good catch. Thanks!
Want results from more Discord servers?
Add your server