Read two txt files and set to variable bat
Posted: 30 May 2014 11:31
Hi Good evening. I would like to read two text files and set variables in the .bat file
One of the files is Name.txt and other is the lastName.txt
In Name.txt i have
John
Mike
Jonson
And in the lastName.txt i have
Smith
Michell
Brown
I try this
@echo on
set /a number=0
:begin
for /f "skip=%number%" %%G IN (name.txt) DO if not defined name set "name=%%G"
for /f "skip=%number%" %%H IN (lastName.txt) DO if not defined lsName set "lsName=%%H"
echo %name% %lsName%
set /a number = number +1
pause
goto begin
The idea is simple. Print on the prompt the name and the last name, reading the two data files and set together in different variables. Sorry, I believe the logic is simple, but I could not make it work.
One of the files is Name.txt and other is the lastName.txt
In Name.txt i have
John
Mike
Jonson
And in the lastName.txt i have
Smith
Michell
Brown
I try this
@echo on
set /a number=0
:begin
for /f "skip=%number%" %%G IN (name.txt) DO if not defined name set "name=%%G"
for /f "skip=%number%" %%H IN (lastName.txt) DO if not defined lsName set "lsName=%%H"
echo %name% %lsName%
set /a number = number +1
pause
goto begin
The idea is simple. Print on the prompt the name and the last name, reading the two data files and set together in different variables. Sorry, I believe the logic is simple, but I could not make it work.