@echo on ::Set BATCH Input Directory set batchdir=e:\meta ::Set the input file containing the list set infile=%batchdir%\DDNs3 set infile2=%batchdir%\DDNsUid2 ::If exists, we remove output file rm DDNs3.ldif ::For loop below process each line in the input list. :uid FOR /F "tokens=* delims=" %%i IN (%infile%) do ( echo dn: %%i echo changetype: modify echo replace: employeeNumber call :loop2 ) goto :eof :loop2 FOR /F "tokens=* delims=" %%k IN (%infile2%) do ( echo employeeNumber: %%k echo. call :uid ) :eof