|
Sample Scripts |
![]() ![]()
|
|
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
Synching 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:\MyLog.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:\MyFolder 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 @MyScript.txt MyFile.txt YourFile.txt MyReport.txt
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:\MyLog.txt # Set the comparison criteria criteria timestamp size # Load source and target folders load C:\MyFolder 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:\MyLog2012-12-31.txt # The exact format depends on your regional and language settings log verbose append:C:\MyLog%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:\MyFolder C:\YourFolder folder-report layout:summary & options:display-mismatches,column-attributes,column-timestamp,column-size & output-to:MyReport.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 a zip 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:\MyFolder C:\MySnapshot.bcss # Expand to affect subfolders and files expand all # Select updated files select left.diff.files left.orphan.files # Copy changes to a zip file copyto left path:relative C:\MyArchive.zip # Update the snapshot snapshot save-crc left output:C:\MySnapshot.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:\MyFolder C:\YourFolder # 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:\MyReport.txt
|