Based on your comments, you can save the sort counter, and in your nested loop look for the correct identifier based on this counter. I'm not even sure that this is possible.
Something like this is possible (unverified):
set COUNTER = 0 for /f %%i in (%users%) do ( set /A COUNTER = %COUNTER%+1 goto :callInnerLoop %%i %COUNTER% ) goto :EOF :callInnerLoop SET LOCALCOUNTER=0 for /f %%i in (%id%) DO ( set /A COUNT=%COUNT%+1 if (!COUNT!=%2) ( REM FOUND %ID% goto :EOF ) )
This is really dirty code, but the script package hardly seems to be the right tool for the job. It would be much easier if you can combine the files (for example, a CSV file with "USERNAME; ID" on each line). Otherwise, I would recommend switching to a more powerful scripting language such as powershell.
source share