2 or more FOR loops in command shell merging fileA line1 with fileB line1, &c.
- by rfransix
Hi, i'm trying to build an ldif import file. I have 2 files, one with the DN and another with the employeeNumber, they match up line for line.
Here's the code that does not work:
@echo on
::Set BATCH Input Directory
set batchdir=e:\Meta
::Set the input file containing the server list
set infile=%batchdir%\DDNs3
set infile2=%batchdir%\DDNs4
::If exists, we remove output file
Rm DDNs3.ldif
::For loop below process each line in the input list.
FOR /F "tokens=* delims=" %%i IN (%infile%) do (
FOR /F "tokens=* delims=" %%k IN (%infile2%) do (
Echo dn: %%i
Echo changetype: modify
Echo replace: employeeNumber
Echo employeeNumber: %%k
)
) DDNs3.ldif
I've tried several variations, including:
::For loop below process each line in the input list.
FOR /F "tokens=* delims=" %%i IN (%infile%) do (
Echo dn: %%i
Echo changetype: modify
Echo replace: employeeNumber
FOR /F "tokens=* delims=" %%k IN (%infile2%) do (
Echo employeeNumber: %%k
echo.
)
) DDNs3.ldif