Page 1 of 1

How can you compare two files Binary and notify?

Posted: 15 Oct 2019 06:52
by stondesign
How can you compare the [FILE1.bin] and [FILE2.bin] and then notify ECHO if file 1 is different from file 2?


I would like to do such a thing!

FILE 1 = FILE 2
if it is equal give command ECHO OK
if it is different give command ECHO ERROR

Re: How can you compare two files Binary and notify?

Posted: 15 Oct 2019 07:10
by stondesign
the files I have to compare are in HEX

Re: How can you compare two files Binary and notify?

Posted: 15 Oct 2019 08:31
by elzooilogico

Code: Select all

fc /b path\file1.bin path\file2.bin
if %errorlevel% neq 0 (
  echo(files are different
) else (
  echo(files are identical
 )
see

Code: Select all

fc /?
for further information, and

Code: Select all

for /f
about to capture output of a command

Re: How can you compare two files Binary and notify?

Posted: 15 Oct 2019 09:17
by dbenham
Similar to elzooilogico's answer, but more efficiently and without extraneous output:

Code: Select all

fc /b file1.bin file2.bin >nul && echo OK || echo ERROR