Solved Batch to Assign some word in each line

June 15, 2011 at 01:10:31
Specs: Windows XP
Hi, team

i want to create a batch file so that ABC.txt file is there and it consists of aroun 100 to 1000 lines date like
40407XXXXXXXXXXXXXXXXXXXXX
40407XXXXXXXXXXXXXXXXXXXXX
.
.
.
.
in want to change the file to

ZMIO:IMSI=40407XXXXXXXXXXXXXXX;
ZMIO:IMSI=40407XXXXXXXXXXXXXXX;
....
.
.
.
in brief
AT the start of each line i have to get ZMIO:IMSI=
AT the end of each line we have to get semicolon ;

any help please..!!!


See More: Batch to Assign some word in each line

Report •


#1
June 15, 2011 at 07:53:00
@echo off > "ABC.new"
for /F "delims=" %%a in ('type "ABC.txt"') do echo.ZMIO:IMSI=%%a;>> "ABC.new"
del "ABC.txt"
ren "ABC.new" "ABC.txt"


Report •

#2
June 16, 2011 at 20:31:57
Hi,
Thank a lot.

can i do this for multiple text files exist in the same folder??

i want to convert all the text files into that format!!


Report •

#3
June 17, 2011 at 03:58:03
✔ Best Answer
The following script applies to all .txt files stored in your folder; beware all text files will be modified.

@echo off
cd /D Your_Folder
for %%j in (*.txt) do (
  type nul > "%%~nj.new"  
  for /F "delims=" %%a in ('type "%%j"') do echo.ZMIO:IMSI=%%a;>> "%%~nj.new"
)
del *.txt
ren *.new  *.txt


Report •

Related Solutions

#4
July 20, 2011 at 06:31:06
Hi,
above solution is working fine for files of size KB's.

whenever i'm trying for a text file of 10 mb it takes more than 30 min.(i waited for 30 mins then closed the cmd prompt).

is there any faster way to do this?


Report •


Ask Question