replacing the value by theoccurence

Intel / Core(tm)2 duo
January 22, 2009 at 06:21:44
Specs: Windows XP, core 2 duo
Hi,

I am having input file which is having data as shown below

Tablename=one
Tablename=two
Tablename=three
Tablename=four

i want to replace the one as 1one,two as 2two,three as 3three, and four as 4four.

please provide some solution for this one.

Thanks.


See More: replacing the value by theoccurence

Report •


#1
January 22, 2009 at 07:13:11
backup your files before using this as a precaution!
Hope it works.

set count=0
setlocal enabledelayedexpansion
for /f "tokens=* delims= " %%j in (myfile.txt) do (
set /a count +=1
set line=%%j & echo Tablename=!count!!line:~10!>>newfile.txt
)
start newfile.txt


Report •

#2
January 22, 2009 at 18:47:25
Thanks for your reply.

Iam getting this error

setlocal: execute permission denied
syntax error at line 5: `"tokens=* delims= "' unexpectedb


Report •

#3
January 23, 2009 at 04:56:33
try this...

set count=0
setlocal enabledelayedexpansion
for /f %%j in (myfile.txt) do (
set /a count +=1
set line=%%j & echo Tablename=!count!!line:~10!>> newfile.txt
)
start newfile.txt


Report •

Related Solutions

#4
January 27, 2009 at 12:47:07
Did it work?

Report •

#5
January 28, 2009 at 08:25:20
H lee,

No need for set count=0


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#6
January 28, 2009 at 08:45:07
Thanks for the tip, I always do that!

Report •


Ask Question