need big help again
File1:
\\server2\share1,\\serverdfs\dfs\test2
\\server1\anothershare,\\serverdfs\dfs\test1
File2:
\\server2\share1,/fs7/server1/share1
\\server1\anothershare,/fs1/serverx/share1
\\server4\newshare,/fs7/server1/share1
Script:
@ECHO OFF
DEL file3 2 > nul
FOR /f "tokens=1*delims=," %%i IN (file1.txt) DO (
FOR /f "tokens=1*delims=," %%a IN (file2.txt) DO (
IF /i "%%i"=="%%a" >>file3 ECHO %%i,%%j,%%b>file3.txt
)
)
The output is something like this:
\\server2\share1,\\\serverdfs\dfs\test2,/fs7/server1/share1
\\server1\anothershare,\\\serverdfs\dfs\test1,/fs1/serverx/share1
The script will search for matches (first field = anything before the comma) between both files (file1.txt & file2.txt).
The problem is for example with \\server4\newshare which is only present on file2.txt.
In this case both of these lines have the same second field:
\\server2\share1,/fs7/server1/share1
\\server4\newshare,/fs7/server1/share1
Can you think of anything in order to show an output similar to this:
\\server2\share1,\\\serverdfs\dfs\test2,/fs7/server1/share1
\\server1\anothershare,\\\serverdfs\dfs\test1,/fs1/serverx/share1
only_at_file2.txt, \\server4\newshare,/fs7/server1/share1 same path as \\server2\share1
Run like:
Contents of
script.awk:Results:
If there are duplicate paths, this will show the last path found in
file2.txt(i.e.values[$2]=$1will override previous paths). For example, if now another server with a path of/fs7/server1/share1is found infile2.txt, the output server will be\\server4\newshare