Saving file formats

I can't think of a good any way to solve this with a path format, but a script can handle this rather easily.

function OnInit(initData) {
    initData.name = 'SortByNameOrModified';
    initData.version = '2024-01-30';
    initData.url = 'https://resource.dopus.com/t/saving-file-formats/48421';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

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

    var tab = afterFolderChangeData.tab;
    if (String(tab.path).indexOf('D:\\Sync\\ClientData\\') < 0) return;

    var hasSubFolder = false;
    var folderEnum = DOpus.FSUtil().ReadDir(tab.path);
    while (!folderEnum.complete && !hasSubFolder) {
        var folderItem = folderEnum.Next();
        hasSubFolder = folderItem.is_dir;
    }

    var cmd = DOpus.Create().Command();
    cmd.SetSourceTab(tab);
    cmd.RunCommand('Set SORTBY=' + (hasSubFolder ? 'name' : 'modified'));
}

Save EventSortByNameOrModified.js.txt to   ↓

%appdata%\GPSoftware\Directory Opus\Script AddIns

How to use buttons and scripts from this forum

Set SORTBY