Edit and Replace text with batch

June 23, 2010 at 02:57:40
Specs: Windows XP, P4, 512mb
I have a text file that contain a huge data and want to replace some data. Text name is mt940.txt contain text is :

:20:201006170828153
:25:186350587
:28:153
:60F:C100602IDR879511164,
:61:1006020602DR313600,NTRF//
:86:TARIK TRF | PEMINDAHAN KE 760360200001004 | PT LAKSANA TATA INDONES A | 258/BPBR-LTI/05 |0020005520DG10
:61:1006020602DR3000,NTRF//
:25:186350587
:28:154
:60F:C100603IDR462231690,
:61:1006030603CR918000000,NTRF//
:86:SETOR TRF (NPB) | PEMINDAHAN DARI 186351138 | fx deal usd 1 vs idr 9180 | equiv 918000000
:61:1006030603DR55639500,NTRF//
:25:186350587
:28:155
:60F:C100604IDR703646190,
:61:1006040604DR440000000,NTRF//

I want to change ":25:186350587" with ":25:00186350587" in all text.

Can anyone help me with the batch file?

Thanks
andirst


See More: Edit and Replace text with batch

Report •


#1
June 23, 2010 at 04:15:45
@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (mt940.txt) do (
set S=%%a
set S=!S::25:186350587=:25:00186350587!
>> newfile echo.!S!
)


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

M2


Report •

#2
June 23, 2010 at 18:33:37
It works M2.
But how if the file not just mt940.txt for example BP-MT940.txt or BP-MT940-Jun.txt
I mean the batch file automatically know it.

Thanks alot

Andi


Report •

#3
June 23, 2010 at 19:53:56
@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%t in ('dir/b/a-d *.txt) do (
for /f "tokens=* delims= " %%a in (%%t) do (
set S=%%a
set S=!S::25:186350587=:25:00186350587!
>> newfile echo.!S!
)
)


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

M2


Report •

Related Solutions

#4
June 23, 2010 at 23:11:13
Ok M2

Thanks alot

Andi


Report •


Ask Question