set var=this-is-a-test
ECHO I would like to convert the value of this variable to "this%_%is%_%a%_%test"
I tried with:
SET VAR=%VAR:-=%_%%
But doesn't work :(
Please help
set var=this-is-a-test
ECHO I would like to convert the value of this variable to "this%_%is%_%a%_%test"
I tried with:
SET VAR=%VAR:-=%_%%
But doesn't work :(
Please help
Because of the way percents are used for variables it messes up what you are trying to do. One way around this is with delayed expansion. You also have to escape the percent by putting two of them in a row %%.
Something like:
Setlocal EnableDelayedExpansion
set _name=s-t-r-i-n-g
set _name=!_name:-=%%_%%!
echo %_name%