fc.exe return value

  • Thread starter Thread starter Angel Tsankov
  • Start date Start date
A

Angel Tsankov

I use fc.exe to perform binary comparison between files. How can I know
in a batch script if they are different?
 
I use fc.exe to perform binary comparison between files. How can I know
in a batch script if they are different?

Use "find.exe" and test the errorlevel.

@echo off
fc /b file1 file2|find /i "no differences">nul
if errorlevel 1 echo miscompare
if not errorlevel 1 echo compared ok
 
There are many ways to do this ... here's just another possibility -

fc c:\f1.exe c:\f2.exe /b >nul 2>&1 && echo Same|| echo Different

Note that the absence of any one of the files can cause a false positive
and may need to be handled depending upon your requirements.
 
Back
Top