Compare and Merge Specified Variables in Text Files

I created this to compare two text lists. When the MAC address matches up, the old and new computer are outputted to a third file (which was to be used for renaming new, randomly named machines back to their original names).

@Echo off
rem looks at 2 text files
rem the first text file contains mac address and old computer name
rem the second text file contains mac address and new computer name
rem the script runs and matches up the old name and new name and
rem outputs that data to a third text file
Title Administrative Compare and Output
color 0a

REM —————————————————————————————————————————–
for /f “tokens=1,2 delims=,” %%a in (FILE1.txt) do (
for /f “tokens=1,2 delims=,” %%c in (FILE2.txt) do (
echo COMPARE MAC1-%%a to MAC2-%%c
if %%a == %%c echo SUCCESS! && echo %%b %%d & echo %%b,%%d>>computers.txt

rem timing, remove to speed up
ping -n 2 127.0.0.1>nul
)
)
REM —————————————————————————————————————————–
echo COMPLETE!
pause

Basic illustration of what happens

email me