read each line and append number

Microsoft Windows server 2003 enterprise
June 27, 2011 at 10:23:55
Specs: window 2003
Hi guru,
i have a text file containing:

how do i get the following result using batch file or vbs:
1. fruit1: apple
2. fruit2: banana
3. fruit3: peach
n. fruitn: orange

Thanks in advance !!

See More: read each line and append number

Report •

July 6, 2011 at 12:20:09
does this work for you? it's a batch file where fruit_list.txt is the list of fruits (apple banana peach) and fruity.txt is the output file.

@echo off
setLocal EnableDelayedExpansion
del fruity.txt
set /p var=<fruit_list.txt
set count=
for /f "tokens=* delims= " %%a in (fruit_list.txt) do (
set /a count=count+1
set var1=%%a
echo !count!. fruit!count! !var1! >> fruity.txt

Report •
Related Solutions

Ask Question