Solved Find and Replace String BAT

May 31, 2012 at 11:17:48
Specs: Windows XP
I would like to find and replace string with another string from a text files using batch dos command. I am able to find the string but couldn't replace it.
for example: i want to replace SHARED with YES. Any help is appreciated.

for %%a in (*.log*) do find "SHARED" <%%a >> fuids.txt

See More: Find and Replace String BAT

Report •

May 31, 2012 at 22:37:33
Post a few lines of the file.

Life is too important to be taken seriously.


Report •

June 1, 2012 at 00:43:45
✔ Best Answer
Prolly this would work:
@echo off
setlocal EnableDelayedExpansion
for %%b in (*.log) do (
 for /f "tokens=*" %%a in (%%b) do (
 set LineFromLog=%%a
 echo !LineFromLog:SHARED=YES! >> %%b.out


Report •

June 1, 2012 at 10:21:39
I copied two lines from the file. I want to replace string Connection: with *

Thu May 31 05:18:30 EDT 2012 INFO: Test Success TS:20120531101829z uid:dpcsstest sessionID:qmam4Qs7VzzseNO/jkYlG1nELNo= ConnectionTS:20120531101829z Connection:0.031 ReadTS:20120531101829z Read:0.016 WriteTS:20120531101830z Write:0.016
Thu May 31 05:18:42 EDT 2012 INFO: Test Success TS:20120531101841z uid:dpcsstest sessionID:pifkEqaF7lQFfcMAv6JMEhsRgl0= ConnectionTS:20120531101841z Connection:0.032 ReadTS:20120531101842z Read:0.031 WriteTS:20120531101842z Write:0.015

Report •

Related Solutions

June 6, 2012 at 11:01:38
Holla, your code helps. Thanks for the information.

Report •

Ask Question