Hi contrex,
I did find a small bug in the above code, regarding listing text lines which appear in FILE1.TXT but not FILE2.TXT.
The good news is I've fixed the bug. See new version below, which also handles double-quotes without needing any pre-processing :-
C:\> type diffline2.bat
@for /F "delims=" %%L in (%1) do @( set DIFF_LINE1=%%L& set DIFF_LINE1=!DIFF_LINE1:"=DOUBLEQUOTE!
set DIFF_FOUND=0
for /F "delims=" %%M in (%2) do @( set DIFF_LINE2=%%M& set DIFF_LINE2=!DIFF_LINE2:"=DOUBLEQUOTE!
if "!DIFF_LINE1!"=="!DIFF_LINE2!" set DIFF_FOUND=1
)
if !DIFF_FOUND!==0 echo %%L
)
C:\> type file1.txt
C:\DIR1
C:\DIR12
C:\DIR123
C:\> type file2.txt
C:\DIR1
C:\DIR123
C:\> diffline2 file1.txt file2.txt
C:\DIR12
C:\>
NOTE that this batch file MUST be run with cmd.exe "/V" flag, because it requires "delayed environment variable expansion". Batch file will NOT work correctly without cmd.exe "/V" flag.
Batch file tested using Windows XP [Version 5.1.2600].
Best regards,
James