Your two lists are separated ones: if you nest one for
into the other one, you are multiplying the number of results. There is no way to process both lists in the same for
, unless you convert the lists into two arrays and then process both arrays in the same for
, that is, process the elements of the two arrays with same index. For example:
setlocal EnableDelayedExpansion
set Client_ID[1]=BJCH
set Client_ID[2]=BORG
etc...
set PartNo[1]=1
set PartNo[2]=2
etc...
for /L %%i in (1,1,6) do echo !Client_ID[%%i]! !PartNo[%%i]!
You may also simulate previous processing ("two elements with same index") this way:
@echo off
setlocal EnableDelayedExpansion
set Client_ID=BJCH,BORG,FGMS,SVIN,JEFF,NWIL
set PartNo=1,2,9,10,12,20
set i=0
for %%A in (%Client_ID%) do (
set /A i+=1, j=0
for %%B in (%PartNo%) do (
set /A j+=1
if !i! equ !j! echo %%A %%B
)
)
EDIT: Output example added
BJCH 1
BORG 2
FGMS 9
SVIN 10
JEFF 12
NWIL 20