COMPARE.TXT 26 September 2002 http://ftp.aset.psu.edu/pub/ger/fortran/hdk/compare.txt Windows 9x/ME/NT/2000 Fast Binary File Compare H. D. Knoble, hdkLESS at SPAM psu dot edu Penn State University Center for Academic Computing Purpose: To compare two files as though they were BINARY. This is NOT to show what files' records are different, but rather to do a fast compare of two files for being identical or different, and to tell how many characters from the beginning of the files match. Syntax: (1) COMPARE [fileid1 [fileid2]] [/QUIET | -QUIET] or (2) COMPARE or (3) COMPARE c:\path\fname.ext d:\path\= or (4) COMPARE ? or /? or /h or -? or -h or (5) From Win 9x/ME/NT/2000 Explorer, drag and drop two files to COMPARE.EXE icon or drag one file to this icon and second file to the TITLE BAR of the resultant DOS prompt screen. where: (1) compares fileid1 with fileid2; COMPARE recognizes Windows 9x/ME/NT/2000 long file names and works in 32-bit (protected) mode. (2) prompts for fileid2 and or fileid1 (3) sets the fname.ext portion of fileid2 equal to the fname.ext portion of fileid1. (4) Displays brief help. Use: See the COMPARE.EXE module in the same FTP subdirectory as COMPARE.TXT. That is the URL: ftp://ftp.cac.psu.edu/pub/ger/fortran/hdk/compare.exe COMPARE.EXE may be run from Windows START/RUN command, or MS-DOS Prompt, or as an Icon (since it will prompt for two fileids), or an Icon that can be drag and dropped to. COMPARE.EXE may be called from another Windows app using the two argument call, including from Windows Explorer to drag and drop one or two files a time to the COMPARE.EXE Icon. Results: The fileids and number of characters matched with the compare is displayed along with a message indicating that either files are identical or that they differ. If they differ, a character count (file offset origin 1) and Hexadecimal representation of the first chararacter that differs is displayed. DOS Errorlevel is set to zero if the files are identical, or 1 otherwise. If ASCII file are compared, line end sequence CR and/or LF are counted and compared; that is, all files are treated as BINARY. The option /QUIET /quiet -QUIET -quiet may be used to suppress displayed results; this is for programs or scripts invoking COMPARE and relying on Errorlevel return code. Examples: COMPARE ? displays brief help (command syntax). COMPARE c:\WINDOWS\xxx.dll a:\xxx.dll compares the two files and displays messages indicating results as shown above COMPARE c:\WINDOWS\xxx.dll a:\xxx.dll /quiet compares the two files and suppresses displayed output. COMPARE c:\WINDOWS\xxx.dll A:\= sets second fileid equal to a:\xxx.dll and does the compare. To create a DOS Batch file that compares all files in one subdirectory with those of same filename.ext in another subdirectory use Batch commands: REM binary compare each file in %1 to companion in %2 REM and put in log file COMP.LOG. for %%f in (%1\*.*) do COMPARE %%f %2\= >> comp.log Source code, subprograms FGETCMD and FGETSIZE, give several vendor specific codes to: (1) interrogate option string passed to COMPARE.EXE; and (2) to get file sizes of the input files. Compilers: COMPARE.EXE is the compiled result of COMPARE.FOR using Compaq (formerly Digital) Visual Fortran, Version 6.6B with options: /optimize:5 /nocheck COMPARE.FOR will also compile and run using: Salford FTN95, Lahey F90/LF95, and Watfor77(Old DOS version); see comments for source code changes. Author: Herman D. Knoble, Penn State Center for Academic Computing hdk at psu dot edu, +1 (814) 865-0818 Also see: Windows 9x/ME/NT/2000 and DOS native command, FC /? Note that FC can produce voluminous output which may not be suppressable; so FC does not produce a summary like COMPARE. Also FC compares files one character at a time, so is much slower than COMPARE - prohibitively so for very large files. One thing FC does do that COMPARE does not (without a batch file - see above) is handle wildcard fileids; that is, sets of files in one command. For a good "intelligent" free ASCII, HTML, or MS Word file comparison program for Win32 platforms, see: http://www.ComponentSoftware.com/csdiff/dlcsdiff.htm This shows (highlights in one of two formats) HOW two files are different. In addition to intelligently comparing two files, CSDIFF also compares two directory structures for identical file content; and it does this by actually comparing each file pair in the two subdirectories bit for bit; it then produces a report summarizing a comparison of the subdirectory contents. There is an option for including the "children" subdirectories in the CSDIFF directory compare. ---------------------------------------------------------------------------