.bat file to compare two text files and output the difference .bat file to compare two text files and output the difference windows windows

.bat file to compare two text files and output the difference


The Simplest and fastest method is using findstr command it will compare and return the result to new file here the script

findstr /vixg:Z:\misc\test1.txt Z:\misc\misc\test2.txt > Z:\misc\misc\test3.txtfindstr /vixg:<source file> <target file> > outputfile

here

/v   : Prints only lines that do not contain a match./i   : Specifies that the search is not to be case-sensitive./x   : Prints lines that match exactly./g: file   : Gets search strings from the specified file.


You can try something like this:-

  @echo off   :main   fc c:\filename r:\filemame > nul   if errorlevel 1 goto error   :next   echo insert next CD    pause  goto main  :error  echo failed check

From the source


You might want to check this out:

http://gnuwin32.sourceforge.net/packages.html

There are ports of *nix utilities, including one for diff so you won't have to reinvent the wheel.