Re: Global Change in text files



On Wed, 21 Sep 2005 08:40:47 -0400, "Jeff Belorit"
wrote in microsoft.public.windows.server.scripting:

>I have about 100 .txt files in a directory that I need to make a global
>change to. I think there is a way to do this with the find command in a
>batch program.
>
>Currently, all of the files have lines of text that point to the path
>c:\inetpub\ftproot. I need to modify this path to
>c:\ftpdata\users
>
>Does anyone have a quick script to do this?

Looks like a job for SED; see: (<http://www.student.northpark.edu/pemente/sed/sedfaq4.html#s4.41>
and <http://www.student.northpark.edu/pemente/sed/sedfaq4.html#s4.43>),
or other similar utilities, e.g. <http://www.funduc.com/search_replace.htm>.

With SED, this should work:

FOR %n IN (*.txt) DO SED "s/c:\\inetpub\\ftproot/c:\\ftpdata\\users/g' %n >%~nn.new

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
.



Relevant Pages