Consulting

This add-in should do what you want (quick shot, might need refinement).

function OnInit(initData) {
    initData.name = 'TabAddParentname';
    initData.version = '2021-10-11';
    initData.url = 'https://resource.dopus.com/t/consulting/39552';
    initData.desc = 'Add parentname to tabname';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

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

    var tab = afterFolderChangeData.tab;
    var srcPathFirstLetter = String(tab.path).substring(0, 1);
    
    if (srcPathFirstLetter == ':' || srcPathFirstLetter == '/') {
        var newTabName = DOpus.FSUtil().DisplayName(tab.path);
    } else {
        var vecPath = tab.path.Split();
        var k = vecPath.count;
        var newTabName = (k > 2 ? vecPath(k - 2) + '\\' : '') + vecPath(k - 1);
    }

    if (newTabName == tab.displayed_label) return;

    var cmd = DOpus.Create().Command();
    cmd.SetSourceTab(tab);
    cmd.RunCommand('Go TABNAME="' + newTabName + '"');
}

EventTabAddParentname.js.txt (1015 Bytes)


How to use buttons and scripts from this forum

(edit: 2nd version handles special folders a bit better)

2 Likes