The problem is the data you originally presented:
File1
\\server2\share1,\\serverdfs\dfs\test2
\\server1\anothershare,\\serverdfs\dfs\test1
File2
\\server1\share1,/fs7/server1/share1
\\server2\anothershare,/fs1/serverx/share1
In file1, the first field of the first line is "\\server2\share1" which
does NOT match the first token on the first line in File2,
"\\server1\share1"
That's why showing real data is preferred - censored to remove
identifying information like email addresses if required.
Now assuming that the first file is to be matched against
File2
\\server2\share1,/fs7/server1/share1
\\server1\anothershare,/fs1/serverx/share1
to produce the output you nominate in file file3 then this should do the
job:
@ECHO OFF
DEL file3 2>nul
FOR /f "tokens=1*delims=," %%i IN (file1.) DO (
FOR /f "tokens=1*delims=," %%a IN (file2.) DO (
IF /i "%%i"=="%%a" >>file3 ECHO %%i,%%j,%%b
)
)
Note: 7 lines. Please cut-and-paste as batch can be sensitive to spacing.