script to replace text

Microsoft Windows xp professional w/serv...
September 13, 2010 at 08:05:48
Specs: Windows XP
From the command line, how can I use a script to open a file and search for some symbols and replace them; for example, how can I replace all instances of “+” with "&” and "#" with "a" and "*" with "B"?

Thanks in advanced

J.


See More: script to replace text

Report •

#1
September 13, 2010 at 09:18:15
@echo off > newfile & setLocal enableDELAYedeXpansion

set P=+
set A=^&

for /f "tokens=* delims= " %%a in (myfile) do (
set S=%%a
set S=!S:%P%=^%A%!
>> newfile echo.!S!
)


=====================================
Helping others achieve escape felicity

M2


Report •

#2
September 13, 2010 at 18:42:00
download sed for windows then do this


C:\test>sed "s/\+/\&/g;s/#/a/g;s/\*/B/g" file

GNU win32 packages | Gawk


Report •
Related Solutions


Ask Question