Diff/Merge Toolbar

See Also: External Compare and Merge Tools 2.0
See Also: WinDiff buttons
See Also: Beyond Compare buttons
See Also: "Smart" front end for Beyond Compare

This toolbar collects together various commands related to diffing and merging files and folders.

I use this toolbar fairly often so I created a menu item that toggles it and also has a Ctrl-D hotkey for quick access. (To recreate the toggle button, copy the contents of the Code box into your clipboard, enter Customize mode in Opus, right-click an empty part of your toolbar and select Paste.)

<?xml version="1.0"?>
<button display="both" hotkey="ctrl+D">
	<label>Diffing</label>
	<icon1>#dupepane</icon1>
	<function type="normal">
		<instruction>Toolbar NAME=Nudel-Side-DiffTools STATE=right TOGGLE LOCAL</instruction>
	</function>
</button>

The WinMerge icons come from WinMerge.exe itself, assuming you've installed it to the default location.

On to the toolbar itself:

The top button closes the toolbar.

I gave the buttons abbreviated names to keep the toolbar thin and because I find the short labels are easier to parse.

The "WM" buttons run WinMerge (very good, free diff/merge tool).

WM F: Diff the first selected file in the source folder with the first selected file in the destination folder.

(Aside: Adding the Select SOURCETODEST command to a button or hotkey can speed up selecting the same file in both sides.)

WM F SvS: Diff the first two selected files in the source folder.

WM D: Diff everything in the source folder against the destination folder.

The "WD" buttons do the same thing except they run WinDiff (somewhat archaic but still occasionally useful diff tool which comes with Visual Studio) instead of WinMerge.

The Bin F button checks for binary differences between the first selected file in the source folder and the first selected file in the destination folder. It uses the fc /b command that comes with Windows.

The Grep Dir button prompts you for a string and then searches for it within all files in and below the source folder. For each occurance a message is printed showing the filename, line number and actual line of text. It uses the findstr command that comes with Windows XP and above.

The MD5 buttons run a tool (attached) which generates MD5 checksums of everything in the current folder. (Note: Opus can show MD5 checksums without this tool, e.g. by running GetSizes NODESELECT MD5, but this tool can be useful if you want to save the results into a file and then diff it against the same output for a different folder.)

MD5 Files will print out MD5 checksums for all files.

MD5 to Log asks you for a log file name and writes the checksums into that file.

MD5 Dir will print a single checksum for the entire folder. (This is calculated by generating the usual MD5 output and then calculating the MD5 checksum of that. This calculation isn't standard but can provide a quick way to verify that two folders are identical.)

The XLS->VBA button runs some VBScript (attached) which automates Excel to extract all VBA code into textfiles in a sub-directory created with the same name as the selected XLS file. This provides a decent way to quickly diff XLS files for VBA changes.

Beware that the VBA output files often have extra directives in them which you should remove if you paste them back into Excel's Diabolical VBA Editor. I recommend you only use the files for diffing and not for editing or archival.

To run use the XLS->VBA script you must turn on Trust access to Visual Basic Project in Excel. In Office 2003 this option is under Tools -> Macro -> Security -> Trusted Publishers but, since Microsoft love to randomly re-arrange everything with each release of their major applications, it's probably somewhere completely different in every other version. :slight_smile:

Two versions of the toolbar are attached, one made for Opus 8 and the other tweaked slightly for Opus 9.
Nudel-DiffTools.zip (1.4 KB)
Nudel-DiffTools-Opus9.zip (1000 Bytes)
ExportVBAfromXLS.zip (717 Bytes)
csmd5.zip (30.3 KB)

1 Like

If you want to diff two files with the same name in the source and destination directory you can save yourself the hassle of selecting the destination file by making a button like this:

"C:\program files\WinMerge\WinMergeU.exe" "{filepath$}" "{destpath$}\{file$}"

You don't normally have to include quotes around the {} arguments but in this case they seem to prevent a quote appearing in the wrong place.

You can also automatically select all files in the destination with the same names as those selected in the source by running:

Select SOURCETODEST

That command is also very useful for quickly checking which files two folders have in common without having to go to the synchronize tool in Opus.

Attached is a two-button that makes a great addition to Nudel's DiffMerge toolbar above.

List Files S = D

  • RMB - List only files that exist in both Source and Destination, hiding everything else.
  • LMB - Unhide all files in both Source and Destination (undoing the first button).

Like many of Nudel's buttons, this one is also designed to work from a Dual Lister. If you left-click it with only a single lister window open, you will be prompted for a Destination Path, and then the command continues normally. If you happen to left-click the button with more than one single lister window open, the command will convert the window you clicked the button in to a dual lister and use the path from the other single lister window as the Destination folder.

This button does not make use of filters. It uses several select commands to "sift" through the folders and files in each file display to end up hiding all of those that do not exist in both file displays. Nothing is selected when the command completes and all items are sorted by the same field (Name - Ascending) in both file displays.

The script commands in the buttons require Windows 2000/XP/Vista.
List Files S = D.dcf (6.12 KB)

Both versions of the toolbar has been updated to work around a problem which Reck discovered, when comparing the root of a drive with something else.

If you want a way to always compare Left File vs Right File (rather than Source File vs Dest File), then see this thread:

Great tips.:slight_smile:
I currently use this one for WinMerge

C:\Program Files\WinMerge\WinMergeU.exe /r /e /x {filepath} {filepathdest}

Could it be possible, using DO's commands to first check if there's an equally named file in the destination tab, and only when it doesn't find one, compare left highlighted item against right highlighted item ?

You can't do that using Opus's commands alone but you could do it by adding in a bit of VBScript (or similar) glue between Opus and WinMerge.

For this one...

<?xml version="1.0"?>
<button display="both" label_pos="right" separate="yes">
	<label>Bin F</label>
	<tip>Binary Compare -- Files -- Source vs Destination</tip>
	<icon1>#dupepane</icon1>
	<function type="batch">
		<instruction>fc /b {filepath$} {filepathdest$}</instruction>
		<instruction>pause</instruction>
		<instruction>@nodeselect</instruction>
	</function>
</button>

How can I make it compare two selected files in the source. Currently it compares between source and dest.

I tried fc /b {filepath$} {filepath$} which just compares each of the files to itself.

It's a slight kludge (since it'll go wrong if three or more files are selected), but if you pass it the list of all selected files then it works with two files in the same place:

fc /b {allfilepath$}

Thanks heaps leo, that works great. Tested on more then 2 selected files and it still seemed to work comparing just the first 2. Thanks a lot.