How can you compare two files Binary and notify?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
stondesign
Posts: 22
Joined: 23 Oct 2018 17:28

How can you compare two files Binary and notify?

#1 Post by stondesign » 15 Oct 2019 06:52

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

stondesign
Posts: 22
Joined: 23 Oct 2018 17:28

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

#2 Post by stondesign » 15 Oct 2019 07:10

the files I have to compare are in HEX

elzooilogico
Posts: 128
Joined: 23 May 2016 15:39
Location: Spain

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

#3 Post by elzooilogico » 15 Oct 2019 08:31

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

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#4 Post by dbenham » 15 Oct 2019 09:17

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

Post Reply