For command. Batch file

Microsoft Windows xp professional w/serv...
July 30, 2010 at 15:13:22
Specs: Windows XP
How do I format the For command?
I have this in my script.

for /F "tokens=1-3" %a in (C:\data.txt) do set %a

I am trying to get it to read the first 3 lines of a text file.
text file:

var1=1
var2=2
var3=3
var4=4

and make those variables inside my batch file. the batch file will use the pause command after this. After i load my batch file it just closes.


See More: For command. Batch file

Report •

#1
July 30, 2010 at 15:54:19
Well, I can get the 4 numbers out of the text file. (I'm not to good with the for command)

@ECHO OFF

FOR /f "tokens=2 delims==" %%a IN (test1.txt) DO ECHO %%a
PAUSE

Maybe you can work with that


Report •

#2
July 30, 2010 at 16:49:40
This might help:

@echo off
cls
setlocal enabledelayedexpansion


for /f "tokens=*" %%1 in (c:\data.txt) do (
    set /a line+=1
    if !line! gtr 3 goto printit
    set var!line!=%%1
)

:printit
echo Var1=%var1%  Var2=%var2%  Var3=%var3%





Report •

#3
July 30, 2010 at 19:03:53
@wahine
mind if i just... copy that?

@matt
his hit what i needed right on the head


Report •
Related Solutions


Ask Question