2 or more FOR loops in command shell merging fileA line1 with fileB line1, &c.
Posted
by rfransix
on Stack Overflow
See other posts from Stack Overflow
or by rfransix
Published on 2010-05-24T17:14:30Z
Indexed on
2010/05/24
19:11 UTC
Read the original article
Hit count: 146
Windows
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
© Stack Overflow or respective owner