How can DOS substitute equal signs?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tinfanide
Posts: 114
Joined: 05 Sep 2011 09:15

How can DOS substitute equal signs?

#1 Post by tinfanide » 02 Mar 2012 10:34

Code: Select all

For /F "tokens=*" %%B IN (test.txt) DO (
   SETLOCAL ENABLEDELAYEDEXPANSION
   SET t=is
   SET old=%%B
   SET new=!old:t=!
   ECHO !new!
   
   ENDLOCAL
)


Two questions.
First, can I store the target text ("is") in the variable t and put t within the !!variable? It seems not working.
Second, how can I substitute "=" the equal sign with something else?

I can't do this. There are two equal signs.

Code: Select all

SET new=!old:==!

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: How can DOS substitute equal signs?

#2 Post by foxidrive » 02 Mar 2012 15:28

You can use SED or a search and replace script to replace "is" and "=" with other things.

Post Reply