PDA

View Full Version : Need a simple command line file compare script


06-Jan-2004, 07:07 PM
I need a simple file compare script to run from the command line, but I don't know how to do it.

I would like to compare two text files, FILE1 and FILE2. I would like just the differences that are in FILE2 and pipe them into a new file,FILE3. Is this doable ? Thanks.

BTW, BC2 is a GREAT product !

Craig
07-Jan-2004, 01:16 PM
Hi Stuart,

You can do this with the report (2.0) or file-report (2.1) scripting commands.

report has been deprecated in 2.1, so it won't be updated, and the format is a little complicated. It does work in both 2.0 and 2.1 though. It's fully documented in 2.0's help, under Scripting Reference. The basic syntax is something like:
report format:01d output:FILE3 FILE1 FILE2
file-report was added in 2.1, and is the recommended scripting command. It has a much cleaner syntax and supports the new report features added in 2.1. The final 2.1 release will have an updated help, but for now you can get the information on it at http://www.scootersoftware.com/report21.php. The format for it would be something like:
file-report layout:side-by-side layout-options:display-mismatches output-to:FILE3 FILE1 FILE2
Unfortunately, the current 2.1 beta doesn't handle the comparison filenames, and needs to have a pair of base folders loaded. This will be fixed in the final release, which will be out later this week.

With either script, you'd then run it from the command line, like: BC2.exe @make-report.txt

If FILE1, FILE2, and FILE3 will change, you can use command line variables in the script with %1, %2, and %3. That would make the script
file-report layout:side-by-side layout-options:display-mismatches output-to:%3 %1 %2
And you would run BC like: BC2.exe @make-report.txt FILE1 FILE2 FILE3

07-Jan-2004, 03:47 PM
Thanks Craig! This will make my life much easier. I'll be giving it a try later this evening instead playing around with command line "diff". Thanks again !

15-Jan-2004, 06:50 PM
I tried this with build 214 and am getting a result with just the contents of a single file and no line numbers:

script is:
file-report layout:side-by-side layout-options:display-context,line-numbers output-options:html-color options:line-numbers output-to:%3 %1 %2

command line is:
c:/bin/BC2.exe @c:/bin/make-report.txt d:/increment1.xml d:/increment3.xml c:/bin/diff.html

Any suggestions?

Thanks

18-Jul-2004, 08:06 AM
Hi,

I am also having a similar problem when I use the FileReport command from the script file. The file differences report is created but it shows only one file. I am using the syntax and the script file similar to what has been posted above.

Please tell me where am I going wrong.

Thanks In Advance.

James

Chris
19-Jul-2004, 10:00 AM
The syntax for the command in the script wasn't quite right.

This should work:
file-report layout:side-by-side options:display-context,line-numbers output-to:%3 output-options:html-color %1 %2

The command line syntax is:
bc2 @script.txt file1 file2 report.html