I have a batch file that creates a variable for each line in a text file. I am trying to echo only a certain number of variables based on user input. My Code is
enter code here`set /p num=" What is the number of variables to display? "
setlocal ENABLEDELAYEDEXPANSION
set vidx=0
for /F "tokens=*" %%A in (data.txt) do (
SET /A vidx=!vidx! + 1
set var!vidx!=%%A
)
set var
pause
FOR /L %%H IN (1,1,%num%) DO ( echo varH%)
The first part of my batch works but it is the counter part I am stuck with. I want the output to display the variable output for the number of lines set in %num%. I have tried lots of combinations of brackets and parenthesis etc.
TIA for any help. V.