Number of files in selected zip or archive files

Not super easy, but doable. A script can sum up the values, store the result in a variable, and display it in a button or the status bar.

Here's a script and a button. The column needs to be visible for the script to work.

function OnInit(initData) {
    initData.name = 'SumFileCountTotal';
    initData.version = '2025-10-08';
    initData.url = 'https://resource.dopus.com/t/number-of-files-in-selected-zip-or-archive-files/57418/2';
    initData.desc = 'SumFileCountTotal';
    initData.default_enable = true;
    initData.min_version = '13.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'SumFileCountTotal';
    cmd.method = 'OnSumFileCountTotal';
    cmd.desc = 'SumFileCountTotal';
    cmd.label = 'SumFileCountTotal';
    cmd.hide = false;
    cmd.icon = 'script';
}

function OnSumFileCountTotal(scriptCmdData) {
    var cmd = scriptCmdData.func.command;
    var tab = scriptCmdData.func.sourcetab;

    if (!tab) return;

    var sumFileCountTotal;

    if (tab.selected_files.count > 0) {
        sumFileCountTotal = 0;
        for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
            var item = e.item();
            if (!item.InGroup('Archives')) continue;
            var fct = item.metadata.other.filecounttotal;
            if (typeof fct != 'number') continue;
            if (isNaN(fct)) continue;
            sumFileCountTotal += fct;
        }
    } else {
        sumFileCountTotal = '---';
    }

    tab.Vars.Set('SumFileCountTotal', sumFileCountTotal);
    // DOpus.Output('SumFileCountTotal: ' + sumFileCountTotal);

    cmd.UpdateToggle();
}

Save CommandSumFileCountTotal.js.txt to   ↓

%appdata%\GPSoftware\Directory Opus\Script AddIns
@label:="SFCT: " + $tab:SumFileCountTotal
Set COLUMNSADD=filecounttotal
SumFileCountTotal
XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>SFCT</label>
	<icon1>#newcommand</icon1>
	<function type="normal">
		<instruction>@label:=&quot;SFCT: &quot; + $tab:SumFileCountTotal</instruction>
		<instruction>Set COLUMNSADD=filecounttotal</instruction>
		<instruction>SumFileCountTotal</instruction>
	</function>
</button>

How to use buttons and scripts from this forum

This version is over a year old. Treat yourself to something fresh :slight_smile: