Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to compare two files

409 views
Skip to first unread message

Bob Altman

unread,
Nov 4, 2004, 11:43:02 PM11/4/04
to
Hi all,

Is there an easy way to tell if two files have byte-for-byte identical
contents without displaying anything to the user? I have a batch file that
wants to do different things depending on whether or not two files are
identical. TIA.


Andrew H. Carter

unread,
Nov 4, 2004, 11:57:29 PM11/4/04
to
On Fri, 05 Nov 2004 04:43:02 GMT, "Bob Altman" <r...@nospam.com> scribbled
some thoughts:

NOTE: Best viewed in a fixed pitch font

Type FC /? for the usage, or use this entry from my "book" on
DOS commands.

FC Command
=======================
=======================
Compares two files or sets of files and displays the differences between
them.

FC [/A] [/C] [/L] [/LBn] [/N] [/T] [/W] [/nnnn] [drive1:][path1]filename1
[drive2:][path2]filename2
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2

/A Displays only first and last lines for each set of differences.
/B Performs a binary comparison.
/C Disregards the case of letters.
/L Compares files as ASCII text.
/LBn Sets the maximum consecutive mismatches to the specified number of
lines.
/N Displays the line numbers on an ASCII comparison.
/T Does not expand tabs to spaces.
/W Compresses white space (tabs and spaces) for comparison.
/nnnn Specifies the number of consecutive lines that must match after a
mismatch.


--
Sincerely, | (©) (©)
| ------ooo--(_)--ooo------
Andrew H. Carter | /// \\\
d(-_-)b |

foxidrive

unread,
Nov 5, 2004, 12:51:59 AM11/5/04
to

@echo off
fc /b file.txt file2.txt >nul&& goto :identical

:different
echo the files are different
goto :EOF

:identical
echo the files are the same
goto :EOF

Bob Altman

unread,
Nov 5, 2004, 9:36:03 AM11/5/04
to
Thanks a million. What the heck does "&&" do?

foxidrive

unread,
Nov 5, 2004, 9:41:05 AM11/5/04
to
On Fri, 05 Nov 2004 14:36:03 GMT, Bob Altman wrote:

> Thanks a million. What the heck does "&&" do?

It executes the following statements on errorlevel 0
similarly || executes the following statements on errorlevel 1

0 new messages