Please enable JavaScript to view this site.

Beyond Compare

The following are some sample scripts to show how Beyond Compare can use scripts.  You can either use these scripts as is or model your own scripts after them.

Here is a basic script which copies all of the newer and orphaned files from one folder to another, using a previously created session:

 load "Sync Laptop"

 sync update:left->right

 

Syncing two folders

Here is a more advanced script which syncs two specific folders using advanced filters.  This works the same as loading the folders in a Folder Compare session and performing a "Mirror Left to Right" folder synchronization.

# Turn logging on.

log normal "C:\My Log.txt"

# Load the default session and exclude all but certain file types.

load <default>

filter "*.html;*.htm;*.png;*.jpg"

# Load the base folders.

load "C:\My Folder" ftp://user@website.com/folder

# Copy different files left to right, delete orphans on right.

sync mirror:left->right

 

Comparing two files by name

This script compares two files by name.

file-report layout:side-by-side &

 options:display-mismatches &

 output-to:"%3" "%1" "%2"

 

A sample command line, calling the above script:

BCompare.exe @"My Script.txt" "My File.txt" "Your File.txt" "My Report.txt"

 

Note  An ampersand (&) at the end of a line means that the command continues on the next line.

Note  %1, %2, and %3 refer to the 1st, 2nd and 3rd command line argument, respectively.

Generating a report

This script compares two files by name and generates an html report showing differences with context:

text-report layout:side-by-side &

 options:ignore-unimportant,display-context &

 output-to:"%3" output-options:html-color "%1" "%2"

 

Keeping a web site in sync

This script keeps a web site in sync with development files.

# Turn verbose logging on.

log verbose append:"C:\My Log.txt"

# Set the comparison criteria.

criteria timestamp size

# Load source and target folders.

load "C:\My Folder" ftp://user@website.com/folder

# Filter to only include source files, ignore CVS subfolders.

filter "*.htm;*.html;*.php;*.jpg;*.gif;-CVS\"

# Sync the local files to the web site, creating empty folders.

sync create-empty mirror:left->right

 

Performing a rules-based comparison and logging results to a file

This script logs the script results to a file that uses the current date as part of the name.  The variable %date% is expanded by the script in the format 2012-12-31 on U.S. English systems, on other systems it will match the system locale.  It performs a rules-based comparison of Pascal source files and generates a report of mismatches.

# Log to a file of the form "C:\My Log 2012-12-31.txt".

# The exact format depends on your regional and language settings.

log verbose append:"C:\My Log %date%.txt"

# Compare the text contents of the files.

criteria rules-based

# Only compare Delphi source files, ignore the archive folder.

filter "*.pas;*.dfm;*.dpr;*.inc;-archive\"

load "C:\My Folder" "C:\Your Folder"

folder-report layout:summary &

 options:display-mismatches,column-attributes,column-timestamp,column-size &

 output-to:"My Report.txt"

 

Comparing current folder state to a snapshot

This script compares the current state of a folder to a snapshot from the last time updates were sent out.  Then it copies the changed and new files to an archive file and updates the snapshot of the folder.

option confirm:yes-to-all

# Compare using crc.

criteria crc

# Load current files against snapshot from the last patch.

load "C:\My Folder" "C:\My Snapshot.bcss"

# Expand to affect subfolders and files.

expand all

# Select updated files.

select left.diff.files left.orphan.files

# Copy changes to an archive file.

copyto left path:relative "C:\My Archive.zip"

# Update the snapshot.

snapshot save-crc left output:"C:\My Snapshot.bcss"

 

Generating a report of differences

This script generates a report of only differences.

# Set up basic comparison features.

criteria timestamp:2sec

# Filter out log files.

filter "-*.log"

# Load first comparison.

load "C:\My Folder" "C:\Your Folder"

# Compare files with timestamp differences.

select newer.files older.files

# Generate a report of the differences.

folder-report layout:summary options:display-mismatches output-to:"C:\My Report.txt"