Here's a little script to try (update #2).
function OnInit(initData) {
initData.name = 'RenameTabItemCount';
initData.version = '2022-12-30';
initData.copyright = '';
initData.url = 'https://resource.dopus.com/t/item-count-in-tab-name/43276';
initData.desc = 'Show number of items in folder tab';
initData.default_enable = true;
initData.min_version = '12.0';
}
function OnOpenLister(openListerData) {
DOpus.Output('*** OnOpenLister');
if (!openListerData.after) return true;
AppendItemCount(openListerData.lister.activetab);
return false;
}
function OnActivateLister(activateListerData) {
DOpus.Output('*** OnActivateLister');
if (!activateListerData.active) return;
AppendItemCount(activateListerData.lister.activetab);
}
function OnOpenTab(openTabData) {
DOpus.Output('*** OnOpenTab');
AppendItemCount(openTabData.tab);
}
function OnActivateTab(activateTabData) {
DOpus.Output('*** OnActivateTab');
AppendItemCount(activateTabData.newtab);
}
function OnSourceDestChange(sourceDestChangeData) {
DOpus.Output('*** OnSourceDestChange');
AppendItemCount(sourceDestChangeData.tab);
}
function OnAfterFolderChange(afterFolderChangeData) {
DOpus.Output('*** OnAfterFolderChange');
AppendItemCount(afterFolderChangeData.tab);
}
function OnDoubleClick(doubleClickData) {
DOpus.Output('*** OnDoubleClick');
AppendItemCount(doubleClickData.tab);
}
function OnDisplayModeChange(displayModeChangeData) {
DOpus.Output('*** OnDisplayModeChange');
AppendItemCount(displayModeChangeData.tab);
}
function OnTabClick(tabClickData) {
DOpus.Output('*** OnTabClick');
AppendItemCount(tabClickData.tab);
}
var cmd = DOpus.Create().Command();
var fsu = DOpus.FSUtil();
function AppendItemCount(tab) {
for (var e = new Enumerator(tab.lister.tabs); !e.atEnd(); e.moveNext()) {
var tabItem = e.item();
DOpus.Output('tabItem.path: "' + tabItem.path + '"');
var tabPath = String(tabItem.path);
if (tabPath == '') continue;
tabPath = fsu.Resolve(tabPath);
var tabName = String(tabPath);
if (tabName.substring(0, 2) == '::' || tabName.substring(0, 5) == 'coll:' || tabName.substring(0, 4) == 'ftp:') {
tabName = fsu.DisplayName(tabPath);
} else {
if (tabName.slice(-1) == '\\') {
var tabName = tabName.substring(0, 2);
} else {
var tabName = tabPath.filepart;
}
}
var c = tabItem.all.count;
var newTabName = tabName + (c > 0 ? (' (' + c + ')') : '');
if (newTabName == tabItem.displayed_label) continue;
cmd.SetSourceTab(tabItem);
cmd.RunCommand('Go TABNAME="' + newTabName + '"');
}
}
Save EventRenameTabItemCount.js.txt to
%appdata%\GPSoftware\Directory Opus\Script AddIns
https://resource.dopus.com/t/how-to-use-buttons-and-scripts-from-this-forum/3546