AutoOpenPairedFolder (Add-in)

This add-in will open a paired folder in the destination if it detects a valid folder while navigating a lister.

The implementation is rather basic, there are more options available. See the docs for details.

How to set up and use

Save EventAutoOpenPairedFolder.js.txt to   

%appdata%\GPSoftware\Directory Opus\Script AddIns

Things you might enjoy reading

Docs: FSUtil GetFolderPair
Docs: PairedFolder
Forum: Regex-based Paired Folders - Tutorials
FAQ: How to use buttons and scripts from this forum

The script's inner workings

function OnInit(initData) {
    initData.name = 'AutoOpenPairedFolder';
    initData.version = '2024-06-28';
    initData.url = 'https://resource.dopus.com/t/autoopenpairedfolder-add-in/46353';
    initData.desc = 'Open paired folder in destination';
    initData.default_enable = true;
    initData.min_version = '13.0';
}

function OnAfterFolderChange(afterFolderChangeData) {
    if (!afterFolderChangeData.result) return;

    var tab = afterFolderChangeData.tab;
    if (!tab) return;

    var fsu = DOpus.FSUtil();
    var pairedFolder = fsu.GetFolderPair(tab.path);
    if (!pairedFolder.valid) return;

    var cmd = DOpus.Create().Command();
    cmd.SetSourceTab(tab);

    cmd.RunCommand('Go' +
        ' PATH="' + pairedFolder.path + '"' +
        ' NEWTAB=findexisting' +
        ' OPENINDUAL' +
        ' NOSCRIPT');
}
7 Likes

Damn, that worked a treat! Thank you!

Thanks very much. I had paired my Music Archive folder with my MP3 Player folder, much of which has the same folder structure. After playing a little with your script and turning it off and on a few times I have decided I like it just as it is with the newtab=findexisting. I also set Prefs to include all subfolders.

In Opus 12 I used Leo's Go Parallel script for these folders and found it to be a very useful navigation button with the Toggle and Select command switches.

Using these two scripts together creates all kinds of new scenarios, but what tabs are what can get a little confusing. However, I think in real use this dual scripting will be more useful than a hindrance or a cause of confusion.

Might make sense to add NOSCRIPT to the Go command it runs, to make sure the script doesn't react to folder changes it did itself.

(Definitely needed if NEWTAB=findexisting is removed, but probably a good idea in general.)

1 Like

Update 2024-06-28

  • Added NOSCRIPT
4 Likes

Now even if I remove the line

' NEWTAB=findexisting' +

from the code to make it open the Paired Folder in the same Tab of the destination folder, it works fine. :smiley: Thanks @lxp . Thanks @Leo .

1 Like