"Smart" front end for Beyond Compare

As I recall it should work in a DUAL pane as follows:

If 2 files are selected in SOURCE pane, compare them.
If 2 folders are selected in SOURCE pane, compare them.
If 1 file is selected in SOURCE and 1 file in DEST then compare them.
If 1 folder is selected in SOURCE and 1 folder in DEST then compare them.
Otherwise compare SOURCE and DEST folders.

And if there is no DUAL pane:

If 2 files are selected in SOURCE pane, compare them.
If 2 folders are selected in SOURCE pane, compare them.
Otherwise open Beyond Compare main menu

I am in the process of testing a simpler and more efficient V2 which I expect to post later today.

Regards, AB

Version 2 is attached as a ZIP. To install, extract Beyond Compare.vbs from the zip and copy this file into the /dopusdata\Script AddIns folder. You should then edit the script (via Preferences may be easiest) to point to the correct location of BCompare.exe on your system.




Once the VBS is installed, use the $BC command to execute Beyond Compare. The "smart" compare logic is as described in the previous post above.

Regards, AB
Beyond Compare.zip (1.6 KB)

Hi AB, as you have converted this in to a script package, you could leverage the script configuration, this would mean that users don't need to edit the script to set the path.
In the init you would add something like this

  initData.config.BCPath= "C:\\Utilities\\BC3\\BCompare.exe";

Also, I think its worth updating your first post so people will find the latest version easily.

Thanks wowbagger. Until you pointed it out I had not picked up on the ability to manage user supplied configuration variables. This is a neat way of doing things. I will post updated code and instructions shortly and link from the original post.

Regards, AB

Yep it is very handy indeed. As the user wont need to edit the script you can rename the zip to ops, then they wont need to extract the vb file after downloading. Also if you use an ops file you can include icons with the script. This is nice because it means that you can provide a sample button with an icon without pulling that icon from the bcompare exe.

I have done up a sample, adding the bcompare icons to the zip you provided.
Beyond Compare.osp (6.92 KB)

Version 2.1 is attached as an Opus Script Package. To install, copy the OSP file into the /dopusdata\Script AddIns folder. You should then configure the script via Preferences to point to the correct location of BCompare.exe on your system. Once installed you simply execute the $BC command to execute Beyond Compare. The "smart" compare logic is as described in an earlier post in this thread.

Note that the OSP includes Beyond Compare icons (once again, thanks to wowbagger) which can be used on any button you create to execute $BC.


Change log..

' v2 = simpler, cleaner rewrite
' v2.1 add user configurable path to BCompare.exe via Preferences dialog
' (thanks to wowbagger for the suggestion)
' use fsu.resolve consistently to fully resolve paths

Regards, AB

BeyondCompareV21.osp (7.02 KB)

Hi mate thanks for the update, its working well :slight_smile:.

Couple of comments, you can set the default icon for you method using this

cmd.icon = "BeyondCompare:BeyondCompare";

You can specify a proper script version this way.

initData.name = "Smart Beyond Compare" initData.version= "2.1";

Thanks for two more good suggestions wowbagger. Both are implemented in v2.2 (attached).


To install, copy the OSP file into the /dopusdata\Script AddIns folder (and delete any earlier versions). You should configure the script via Preferences to point to the correct location of BCompare.exe on your system. Once installed you simply run the $BC command to execute Beyond Compare. The "smart" compare logic is as described in an earlier post in this thread.

Regards, AB

Beyond Compare.osp (6.33 KB)

Very awesome mate :slight_smile:

Did you mean to change the small icon to 16x16? The default buttons use 22x22 for small and 32x32 for large.

On my system, the 22x22 was out of kilter with the rest of my icons. I extracted a 16x16 from BCompare.exe and (for me) it is a much better match, as shown.

Regards, AB


I see, that makes sense. The Dopus icons are 22x22, but the small size in an exe (where you are getting your icons from) are 16x16. As all my other icons are 22x22 the 16x16 was looking a little off. I have updated the package locally to have the 22x22 icon.

We can have more than 2 sizes for the icons. So we could provide, a 16x16, 22x22 and 32x32. But I am not sure how we could chose the correct one for our uses.
Cheers mate

Very nice indeed!!

:thumbsup:

Thanks a lot.

I wonder why you called the command "$BC" and not just "BC"/"BeyondCompare" or something.

On the second thought, introducing a "$"-prefix for all script commands might be a good general idea, that way you could easily recognize "externally" introduced functionality.

Just tried your smart front end, and I need to say, it is smart indeed, working flawlessly here. o) Now I wonder if I need to purchase BC, already owning a "CompareIt" license, mhh. o)

In the past I have looked at other tools as well. From my point of view Beyond Compare by far is the most userfriendly.
Meaning : it is very flexible and requires a minimum of 'clicks' and is well Explorer-integrated, supports drag and drop, etc.
Beyond Compare is really a wonderful tool and you won't be sorry.

They have a very active support forum, with developers attending.

Recently they introduced version 4 (beta version xyz, I haven't been able to let it crash though)
Have a look at youtube.com/watch?v=eGAyWvstKCI

e.g. click on a subfolder in the foldertree (left)
then ctrl-click on any other subfolder in the foldertree, you wish to compare
in my case both subfolders are listed side by side (right window panel)
I have cofigured this 'Smart front' as a button on the toolbar,
click on the Beyond Compare-button...
(with thanks to aussieboykie)

Just my 2cents :wink:

=

I started making some small changes to this script today, and ended up adding/changing so much that it's almost a new/separate script in the end.

I'm not sure what to do with this new version, since some of the changes I wanted may not be wanted by everyone, while other changes are definite improvements and would make sense to merge back into the "official" version. I'll upload it here and let AussieBoykie decide which changes, if any, he wants to keep.

I've used "2.2 LDx" as the version string, since it's based on 2.2 from the root post.

2.2 LD3: Beyond Compare.osp (14.4 KB)

History of my edits:

  • 16 November 2023 ("2.2 LD3"):
    • Fixed problem with files that have plugin-archive extensions but aren't really archives.
  • 24 August 2020 ("2.2 LD2"):
    • Small change to add a NEWWINDOW argument (passes /solo switch to make BComp.exe open a new window).
    • Also updated the default/fallback path for Beyond Compare 4.
  • 19 November 2019:
    • Fixed an issue with very high DPIs and/or the large icon size.
  • 12th October 2017:
    • Updated .osp to include high DPI icons.

Here's a summary of what I changed from the original 2.2 in the root post:

  • Requires Directory Opus 11.4 or above.

  • Ensures left and right in Beyond Compare match the left and right in Opus (even if the right is the source).

  • Allows comparing folders with archives (since BC supports this), with a new config option to disable it. (Disabling it also requires you to make changes to BC's own config, to stop it treating archives as folders.)

  • If one item is selected in the source and nothing (or the wrong kind of thing, or too many things) in the dest, it now ignores the destination selection(s) and compares the selected source item on both sides.

    For example, if C:\ and D:\ are the source/dest folders, and File.txt is selected in the source, C:\File.txt and D:\File.txt are compared.

    "Wrong kind of thing" means a file on one side and a folder on the other. (Where archives are considered folders, if that option is enabled.)

  • Fix for when Desktop is compared to another folder. (Compares /desktopdir instead of /desktop virtual folder.)

  • Gets default Beyond Compare exe path from the registry if the script config has no path or has a path that doesn't exist.

    Failing that, it uses the standard Beyond Compare install path, under the 32-bit Program Files folder.

    Default config path is now blank, and should only be set if the above methods need to be overridden.

  • Shows an error message if Beyond Compare exe isn't found.

  • If the path found/configured is for BCompare.exe, it will swap it for BComp.exe (if it exists).

    Using BComp.exe is preferable as it will open new tabs in an existing BC instance. (Could make this an option.)

  • Won't do anything if nothing is to be compared.

    (If people want the button to be able to run BC on its own, it could be a config option. For me it'd just mean having to close BC if I clicked in error, so I added the check.)

    (You can still click the button with nothing selected to launch BC against the source and destination folders, so it's still easy to quickly launch BC.)

  • Won't do anything if either thing to be compared does not exist. (This is mainly for the new case where you can select a file on one side to compare the same thing on both sides.)

  • New small icon matching the 22x22 size of Opus's other small toolbar icons, with 1 pixel padding.

    (Made by resizing the 32x32 icon to 20x20, then adding 1 pixel of padding on all sides, to match the standard icons.)

    (2017: Now also includes high DPI icons.)

  • Removed debug stuff I didn't need and tidied up some of the code, although in the end it's almost a re-write after adding all of the above.

  • Changed command name from $BC to BeyondCompare. (Change it back if you want; I just didn't like it :slight_smile:.) Also changed the description and label to work better with where they are displayed.

2 Likes

Sounds good, thank you! o)

Comparing both versions.. there's really not much left from aussie's release. o)


You have made some interesting modifications and improvements Leo. I had already planned to clean up the "path to BC" determination, recognising that most users will run the executable from the default installation location. Your code for interrogating the registry is not something I have ever come across before and looks to be a very useful snippet to keep. I also like your archive handling and use of BComp, if available, to open in tabs.

My logic for determining what to compare under various circumstances is driven by the way I typically use BC. Your logic is different but I have no doubt many others will prefer "Leo's way". I'll add a link at the top of the thread pointing to your code and description. I certainly plan to incorporate several of your improvements into "my" version and will likely post an update once done and tested.

Regards (and thanks), AB

Many thanks Leo !
:thumbsup:

=

@leo
Sorry, but one last thing..

Maybe you care to add 1 or 2 lines as to how to get this working as a button in the toolbar?
I had the previous one working (with $BC).
Deleted the button, wanted to delete the script (preferences), the last thing was not possible.
try reset, it now refers to a non-existing BC folder, again, I can't delete it,

Anyway, how to get this new .osp working under a toolbar button?

=