Page 1 of 1

Replace space with %20

Posted: 02 Dec 2009 09:03
by SteveT44
Hello,

Can anybody suggest a way to replace spaces in an environment variable with "%20"? The following:

set string=%string: =%%20%

removes the spaces and appends %20%.


Thanks

Steve T.

Posted: 02 Dec 2009 13:58
by avery_larry

Code: Select all

@echo off
setlocal enabledelayedexpansion

set "string=string with a space"
set string=!string: =%%20!
echo %string%

Posted: 02 Dec 2009 14:29
by SteveT44
Just what I needed!

Thanks


Steve