You are not logged in.

#1 11 Mar 2018 17:46

wquatan
Member
Registered: 19 Jun 2012
Posts: 16

% Replace problem

I have a problem with the following :

In
TEST=This Is an example
the spaces need to be replaced with %20
So the string should become "This%20Is%20an%20example"

So I tried the following

TEST=%TEST: =%%20%

But that doesn't seem to work (neither does ^% )

TEST=%TEST: =A%
works fine, so the problem must be with the %

What can been done ?

Offline

#2 11 Mar 2018 18:15

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: % Replace problem

with delayedExpansion:

@Echo off
Setlocal EnableDelayedExpansion
Set TEST=Hello World
TEST=!TEST: =%%20!
Echo %TEST%

Offline

Board footer

Powered by