Assign 1st line in file to variable in batch

Nt / Batch
October 27, 2009 at 08:13:00
Specs: Windows XP
I have a text file and the first line is a number. How can I get this number assigned to a variable inside a batch file?

See More: Assign 1st line in file to variable in batch

Report •


#1
October 27, 2009 at 13:53:46
Hi gman8

Change "set Num=%%a & set Num & exit /b"
to "set Num=%%a & & exit /b" if you dont
the variable Num displayed on screen.
Below is all one line.

@echo off
for /f "tokens=1 delims= " %%a in (GetNum.txt) do set Num=%%a & set Num & exit /b


Report •
Related Solutions


Ask Question