Linked Folder Pairings

Here is a little script add-in that changes the destination if the source gets set to a folder from a specified list.

var destFolders = DOpus.Create.Map();

destFolders('D:\\test') = 'D:\\findtest';
destFolders('F:\\Video2') = 'F:\\Music';

function OnInit(initData) {
    initData.name = 'AutoDest';
    initData.desc = 'Opens a new destination based on source';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

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

    var srcPath = afterFolderChangeData.tab.path;
    if (!destFolders.exists(srcPath)) return;

    var cmd = DOpus.Create.Command();
    cmd.RunCommand('GO PATH="' + destFolders(srcPath) + '" OPENINDEST');
    cmd.RunCommand('Set NAVLOCK=On');
}

EventAutoDest.js.txt (695 Bytes)

This is a little helper button that lets you quickly generate the folder pair entries. Just navigate to the desired combination, hit the button and paste the clipboard into the add-in from above.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var fsu = DOpus.FSUtil();
    var wld = fsu.NewWild();

    cmd.deselect = false;

    var srcPath = wld.EscapeString(clickData.func.sourcetab.path, 'b');
    var dstPath = wld.EscapeString(clickData.func.desttab.path, 'b');

    var line = 'destFolders(\'' + srcPath + '\') = \'' + dstPath + '\';\n';
    DOpus.SetClip(line);
}

GenerateFolderPairs.dcf (1.1 KB)


1 Like