Solved How To Get Each Line Value From Txt File In Cmd

May 29, 2012 at 02:13:08
Specs: Windows XP
hi....
I need to get each line value from txt file in batch script
readme.txt CONTENTS::
AUTHOR: USER
ITERATION: 100
KEY:1234567890
INDEX:2
I need to get USER,100,1234567890 and 2 from text file and need to store in variable.
Can anyone pls help me in solving this.

See More: How To Get Each Line Value From Txt File In Cmd

Report •


#1
May 29, 2012 at 13:10:41
✔ Best Answer
::please test for your needs.
@echo off
cls
setLocal EnableDelayedExpansion
:: draws content from file in this case Mfile.txt please change to yours
for /f "tokens=1-2 delims=:" %%a in (c:\dostemp\Mfile.txt) do (
:: sets counter for next line
set /a n+=1
:: sets variable to %%b which is the part after the :
set list1!n!=%%b
)
set list1
pause
:: in this case it sets
:: list11=USER
:: list12=100
:: list13=1234567890
:: list14=2

mike


Report •

#2
May 31, 2012 at 23:22:23
Thank u mike :)

Report •

Related Solutions


Ask Question