Here's a little script that should do what you want.
function OnInit(initData) {
initData.name = 'AddRemoveLabelColumns';
initData.version = '2024-01-10';
initData.default_enable = true;
initData.url = 'https://resource.dopus.com/t/a-button-check-and-show-status-column-if-there-is-at-least-one-file-folder-has-status/40448/5';
initData.min_version = '12.0';
}
function OnAfterFolderChange(afterFolderChangeData) {
if (!afterFolderChangeData.result) return;
var tab = afterFolderChangeData.tab;
var cmd = DOpus.Create().Command();
cmd.deselect = false;
cmd.SetSourceTab(tab);
var hasLabels = false;
for (var e = new Enumerator(tab.all); !e.atEnd(); e.moveNext()) {
var item = e.item();
if (!item.Labels().count) continue;
hasLabels = true;
break;
}
if (hasLabels) {
cmd.RunCommand('Set COLUMNSADD=status(!,a,0)');
cmd.RunCommand('Set COLUMNSADD=label(!,a,0)');
} else {
cmd.RunCommand('Set COLUMNSREMOVE=status(!,a,0)');
cmd.RunCommand('Set COLUMNSREMOVE=label(!,a,0)');
}
}
Save EventAddRemoveLabelColumns.js.txt toββββ
%appdata%\GPSoftware\Directory Opus\Script AddIns