I'm trying to write a small script which replaces a value in windows' path. Using some sed to replace it is fine (I've got the proper variable):
echo %path% | sed "s/jvms\\[^^\]\+/jvms\\%1/"
This works fine. However, I want to assign that to a new path variable. The way to do that should be
for /f "delims=" %%B in ('echo %path% ^| sed "s/windows/C64/"' ) do call set replaced=%%B
echo %replaced%
Note that the | is escaped as it should. However, the new replaced variable has all the semicolons replaced by spaces. Hence, the output of echo %replaced% is something like c:\C64 c:\program files c:\otherdirectory instead of c:\C64;c:\program files;c:\otherdirectory
This already happens when I don't use any sed, so
for /f "delims=" %%B in ('echo %path%' ) do call set replaced=%%B
echo %replaced%
then returns c:\Windows c:\program files c:\otherdirectory
How can I ensure that the semicolon is not replaced by spaces?