You could use diff
from the DiffUtils and something like this:
diff file1.txt file2.txt | findstr /r /c:"^<" /c:"^>" >file3.txt
The output lines will be preceded by <
or >
, depending on which file the respective line was missing in. If you want to remove those indicators as well, use something like this:
for /f "tokens=1*" %a in (
'diff file1.txt file2.txt ^| findstr /r /c:"^<" /c:"^>"'
) do @echo %b >>file3.txt
Change %a
and %b
into %%a
and %%b
if you want to run this in a batch file.