I want to read only first two lines in a batch file and store them in two different variables. I used this code:
@echo off
for /f "delims=''" %%f in (red.txt) do (
echo file is: %%f
set /A Counter+=1
call :a %counter%
echo Counter After Increment: %Counter%
echo.
)
:a
if %Counter% equ 1 (set "file1=%f"
echo first file is: %file1%)
if %Counter% equ 2 (set "file2=%f"
echo second file is: %file2%)
if %Counter% equ 4 exit
echo Counter after for loop: %Counter%
pause
but variables ‘file1’ and ‘file2’ show blank.
Any thought on how to go about it?
Your try is a bit overkill and the syntax is wrong.
Try this instead