Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and replace text

Status
Not open for further replies.

Kaiaualad

Technical User
Jun 15, 2001
70
0
0
AU
Hi,
As a newbie I am trying to construct a batch file to find all instances of a a word "abc" in a bunch of log files and replace with "xyz".
The Findstr command is great,but The replace command only seems to work at the file level.
Any ideas?

cheers
 
Thanks, but a restriction is that I am unable to use 3rd party software to perform this task.I will have to code it in Wscript or Dos
 
Hello Kaiaualad,

As this is not a script-dedicated forum, I would be very brief and concise here.
Code:
[COLOR=green]logfile="c:\log\test.log"[/color]    '<<edit it
set fso=createobject("scripting.filesystemobject")
on error resume next
set ts=fso.opentextfile(logfile,1,false)
if err.number<>0 then
    wscript.echo "Cannot load the log file. Operation aborted."
    wscript.quit
end if
on error goto 0
s=ts.readall
ts.close
s=replace(s,"abc","xyz")
set ts=fso.opentextfile(logfile,2,false)
ts.write s
ts.close
set ts=nothing : set fso=nothing
regards - tsuji
 
I understand the issue you face, and it is sad, as WinGrep is just a wonderful freeware tool. If you have never visited, it would be worth your while to see how excellent some freeware utilities can be:
I note, if it can help, that MS KB articles have several times reference the WinGrep utiliy I first mentioned. This is not a risky thing to use.

So, straight Microsoft stuff:

. I have used this MS tool in several clever ways: and Change.exe if the issue is .ini files:
. And often use this Resource Kit tool from Microsoft as a reasonable equivalent to the Linux Grep:
Direct download for the Win2k resource toolkit for the Munge.exe tool:
 
Thanks Tsuji - works a treat - also thanks for 3rd party links guys.
 
bcastner,

Yes, good confidence after reading "MS KB articles have several times reference the WinGrep utiliy,.. not a risky thing to use". But I'm still hesitating. I know two sources for wingrep, after doing some research: or Hurricane Software. Big difference: free versus cost. Does anyone know if MS points us to freeware or pay?
 
bcastner:
<quote>
WinGrep is just a wonderful freeware tool.</quote>

When I first come about links to wingrep (distributed via it mentions it is freeware also. I just downloaded/played with it last week. Absolutely agree with you: a wonderful tool.

Then I discover it is a shareware and costs US$30 for registration. Any comment?
 
An exact quote from the TOP of the download page at

A fully-functioning evaluation version is available for download. There are no differences between this and the registered version. It does not time-expire.

This means that it is indeed freeware, but you can "register" the program. It's basically a donation if you want to donate. But you are not required to pay to use the full features of the program for however long you want to.

Computer/Network Technician
CCNA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top