I have a simple batch to write to C:\Program Files (x86)\Data\ori.csv file the folowing information: division, originator name
@echo off
CHOICE /C NS /M "Please Choose Division:"
echo.
if errorlevel 1 set division=A8-NN
if errorlevel 2 set division=A8-NS
:PROMPT
set /P ori= "Add %division% Originator? [(Y)=yes / (N)=No] "
IF /I "%ori%" NEQ "N" goto add (
) else (
goto exit
)
:add
set /p oriname= "Please Enter %division% Originator Name "
echo Division %division% Originator %oriname% has been Sucessfully added
echo %division%,%oriname% >>C:\%programfiles(x86)%\data\Ori.csv
echo.
goto prompt
:exit
pause
the output of csv to be e.g.
A8-NN,Chris
A8-NN,Alfredo
A8-NS,Joe
A8-NN,Patrick
A8-NS,Ann
etc
the data of this .csv is gonna change every 2 months for the divisions (new people assigned in each division)
My problem is that i want in a seperate batch file from ori.csv file to read the data and for a specific division use the choice command to choose one originator
As far i have done this:
CHOICE /C NS /M "Please Choose Division:"
echo.
if errorlevel 1 set division=A8-NN
if errorlevel 2 set division=A8-NS
count=
for /f "tokens=1-20* delims=," %%a in ('type "C:\%programfiles(x86)%\data\Ori.csv"') do (
if %%a== ("%division%)
set b = %%b
set "count=!count!+1"
echo %count% %%b
)
)
What i tried to do is to the %count% variable store a number identifier and to the %b variable store the originator name. How can I use those two variables as input to a choice command?