I am having an issue wrapping my head around this. The thing I am trying to do is list the contents of a text file (%textfile%) with a number in front that increments each time a new line of the text file is printed, then assign that number to the output. It must be in the form of a batch file for my purposes.
Example:
for /f "delims=" %%A in (%textfile%) do (echo %%A & echo.)
Output:
Output1
Output2
Output3
... etc
What I would like it to do:
1. Output1
2. Output2
3. Output3
... etc
This is to be used in a menu that asks you to choose one of the above. Selecting 1 would set Output1 to a variable to be used in another script.
set /P menuSelect=Please make a selection:
for /f "delims=0-%highestVariable%" %%a in ("%menuSelect%") do echo Incorrect input, press any key to try again & pause>nul & goto :otherFunction
Something else I am trying to figure out is how to set the delimter equal to 0 through the highest numerical output in the above code. That's why I set "delims=0-%highestVariable%".
So essentially, how do I output the contents of the text file with a number assigned, then allow the user to select one of the numbered outputs and assign it to a variable.
Any help is appreciated, been stuck on this for a few days.