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.

function OnInit(initData) {
    initData.name = 'AutoOpenPairedFolder';
    initData.version = '2023-10-11';
    initData.url = 'https://resource.dopus.com/t/autoopenpairedfolder-add-in/46353';
    initData.desc = '';
    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');
}

// Prefs PAGE="pairedfolders"

// GetFolderPair
// https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:fsutil

// PairedFolder
// https://docs.dopus.com/doku.php?id=reference:scripting_reference:scripting_objects:pairedfolder

Save EventAutoOpenPairedFolder.js.txt to

%appdata%\GPSoftware\Directory Opus\Script AddIns
3 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.