Page 1 of 1

How can DOS substitute equal signs?

Posted: 02 Mar 2012 10:34
by tinfanide

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:==!

Re: How can DOS substitute equal signs?

Posted: 02 Mar 2012 15:28
by foxidrive
You can use SED or a search and replace script to replace "is" and "=" with other things.