GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Beyond Compare buttons

See Also: "Smart" front end for Beyond Compare
See Also: Diff/Merge Toolbar
See Also: WinDiff buttons

To those who uses Beyond Compare version 3. Here are buttons:

  1. For comparing two files selected in different file displays:

    C:\Program Files\Beyond Compare 3\BCompare.exe" {filepath$} {filepathdest$}
    @nodeselect
    
  2. For comparing two files within same lister:

    "C:\Program Files\Beyond Compare 3\BCompare.exe" {allfilepath$}
    @nodeselect
    
  3. For comparing two folders in two different file displays:

    "C:\Program Files\Beyond Compare 3\BCompare.exe" {sourcepath$|noterm} {destpath$|noterm}
    @nodeselect
    

I made this with great help from WinMerge topic

Regards,
Simon

Update 2017:

You can do even better than this using scripting, which adds more intelligence to the way Beyond Compare is launched from Opus, and lets you have a single button that works in different contexts (e.g. comparing the source/dest folders if nothing is selected, or files if something is selected, etc.)

See this thread for the script method:


(Updated December 2011)

I use a slightly different command so I thought I'd share it here:

  • Replacement for 1 & 3 combined: Compare two files, or two folders, between left and right file displays:

    "C:\Program Files (x86)\Beyond Compare 3\BComp.exe" {leftpath}{file} {rightpath}{file}
    @nodeselect
    

    (32-bit users: Change Program Files (x86) to Program Files in the command.)

    If no files are selected then clicking the button will tell Beyond Compare to compare the left and right folders.

    If you select one or more files in either side of a dual-display window, then click the button, they will be compared against the files with the same names in the other side.

    With multiple files selected, this works best if you configure Beyond Compare to use multiple tabs instead of multiple windows.

    The button also ensures that Beyond Compare's left and right sides match what's displayed in Opus. (e.g. If the right-hand side happens to be active in Opus, it'll still be on the right in Beyond Compare, not swapped to the left.)

That works great for comparing folders, and for comparing files when they have the same names in both folders, and when you are using a dual-display window.

  • Alternative that works with different filenames and separate windows:

    It's also possible to make a similar button that works across two single-display windows, and also works for comparing files which have different names in each side.

    In this case, you have to select the file you want to compare in each side or window, so the button knows what you want.

    The button is also more complex to create, since it requires a User Command.

    Details of it are in a separate thread, File equivalent of {rightpath}/{leftpath}. (You want the first reply, from 2008. My reply from 2011 discusses the method I just gave above.)

These are really handy buttons, but I'm wondering if it's possible to simulate Beyond Compare's Explorer context menu:

Select Left Side
Select Right Side
Compare to...

I'm trying to get this done without incorporating BC's shell into DOpus. I've looked through BC's command line switches but there doesn't seem to be one that forces the selected file to be shown in the right or left pane. There also doesn't seem to be a way to load a single file into BC, navigate to another directory to select a second file, and then execute a "compare to..." command (referring to the previously loaded file in BC).

Does anyone know of a way to get this done without incorporating BC's shell into DOpus? I figured something simple like the following could work, but it doesn't (most likely because I haven't fully understood BC's command line switches)

C:\Program Files\Beyond Compare 3\BCompare.exe" /left {filepath$} @nodeselect

FWIW, I have the following command on my All Files context menu:


Just curious, Jon...

Quite a few of your users, and now you yourself are using BC.

So far, I have not needed anything more than is offered by the DOpus sync tool.

Woulf you mind giving a brief explanation of what it is attracted you about BC?

Anyone else, feel free to comment too.

BC is a diffing tool as well as a sync tool. Opus doesn't do diffing at all.

Ahh...

Thanks Leo.

FWIW: I have a variety of buttons I use with my chosen diff tool... Araxis Merge:

For folder comparisons when I have a dual display lister opened to two different paths I want to compare:

<?xml version="1.0"?> <button backcol="none" display="both" icon_size="large" label_pos="right" textcol="none"> <label>Merge Folders</label> <tip>Send current Folders to Araxis Merge</tip> <icon1>#araxis3</icon1> <function type="normal"> <instruction>@runmode max</instruction> <instruction>/jtools\araxis\merge.exe {l} {r}</instruction> </function> </button>
For file comparisons when I have a dual display lister opened to two different paths, each with files selected I want to compare:

<?xml version="1.0"?> <button backcol="none" display="both" label_pos="right" separate="yes" textcol="none"> <label>Merge Files</label> <tip>Send seleted Files to Araxis Merge</tip> <icon1>#araxis3</icon1> <function type="normal"> <instruction>Set SOURCE=Left </instruction> <instruction>dopusrt /cmd mergefile</instruction> </function> </button>
One of the things I really liked about an update made awhile back to Opus was the addition of {leftpath} and {rightpath} arg codes used in the first button in their short form of {l} and {r}...

The weird thing I'm doing in the second button is done that way to make sure that regardless of which side lister is currently active, the file in the left side file display (top file display when in horizontal mode) is always oriented the same way in my diff tool... which is then called from a user command (mergefile) that runs:

@runmode max
@nodeselect
/jtools\araxis\merge {f} {fd}

...the {l} and {r} handles that for "paths" in folder compares, so it would be kind of nice to have something like {filepathleft$} / {fl} and {filepathright$} / {fr} to do similar for file selections... :slight_smile:.

I like Jon's example of using {filepath$} and {destpath$}{file$} so that you don't have to actually SELECT the second file in the 'other' file display... but it only works when you're comparing files with the same name between source and destination - and very often I'm comparing differently named files in MY work...

@ Jon and Steje - thanks for sharing your buttons! I asked my previously posted question over at the BC forum (if it's possible to simulate the BC Explorer context menu via command line). Unfortunately, it's not. Only their shell extension is able to perform those functions, and must be installed. For now, I'm just going to keep the BC shell integration with DOpus, and add a few of the buttons posted here :slight_smile:

I was wondering if it is possible to use BC to for diff with remote-FTP file without entering FTP credentials in BC - when I try to use Leo's button BC3 tries to open FTP link and asks for credentials...

Maybe it wouldn't be a problem but when launching BC with Leo's button BC3 asks every time for credentials (login and password) even though FTP profile is already saved for this domain (probably because that BC tries anonymous login first)

If a file is selected this code compares a file with the same name in left and right listers. Is it possible to have a button that compares the folder path if nothing is selected, or the first item in each lister if a file is selected?

I thought this would do it, but it always falls back to folder compare.

"C:\Program Files (x86)\Beyond Compare 3\BComp.exe" {sourcepath}{file} {destpath}{filedest} @nodeselect

It already does that.

You are correct my script does what I wanted. Didn't seem to but now I test it again I see it does.

*edit, I misunderstood your reply

Leo, Need small help. I have copied your commands
"C:\Program Files (x86)\Beyond Compare 3\BComp.exe" {leftpath}{file} {rightpath}{file}
@nodeselect

and tried to follow steps to create new buttons using customzie; but I could not get the "paste" options available. Your help is appreciated.

I've expanded the How to add buttons from this forum to your toolbars post so that it explains what to do with raw commands that aren't full XML button definitions.