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')); }