Search and Replace Text

January 28, 2010 at 03:43:07
Specs: Windows XP
Hi all, im searching for a BAT script that searches lines in a txt file that start with a 'bla-bla:', then delete this 'bla-bla:' and echos truncated strings to another txt file, any help will be greatly appreciated thx =)

See More: Search and Replace Text

Report •

January 28, 2010 at 04:30:28
(script not tested)

@echo off & setlocal enabledelayedexpansion
set repl=abcd
set /a len=4
for /f %%a "tokens=* delims=" in (file) do (
set test=%%a
set test=!test:~0,%len%!
if "!test!" equ !repl! (
set test=!test:%len%!
) else (
:: do whatever with lines not having leading string...
:: this arrangement is to pass them on, enable foll. to not
:: set test=
>> outfile echo.!test!

(note: as coded here, blank lines are not passed, exclams in inputstream will fail... )

Report •
Related Solutions

Ask Question