Collection: update file size within

Here is a script that should do the trick by removing and adding the selected items. Maybe try with a copy of your collection first.


JScript
function OnInit(initData) {
    initData.name = 'RefreshCollection';
    initData.version = '2023-06-05';
    initData.url = 'https://resource.dopus.com/t/collection-update-file-size-within/12044';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'RefreshCollection';
    cmd.method = 'OnRefreshCollection';
    cmd.hide = false;
    cmd.icon = 'script';
}

function OnRefreshCollection(scriptCmdData) {
    var cmd = scriptCmdData.func.command;
    var tab = scriptCmdData.func.sourcetab;
    cmd.deselect = false;
    if (String(tab.path).substring(0, 5) != 'coll:') return;
    cmd.RunCommand('Delete REMOVECOLLECTION');
    cmd.SetDest(tab.path);
    cmd.RunCommand('Copy COPYTOCOLL=member');
    cmd.RunCommand('Select FROMSCRIPT');
}

Save CommandRefreshCollection.js.txt to

%appdata%\GPSoftware\Directory Opus\Script AddIns

Add the new command RefreshCollection to a button, hotkey, context menu, etc. like any built-in command.


How to use buttons and scripts from this forum

2 Likes