Extract archives with condition?

Try this. It'll loop through all selected files.

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    var fsu = DOpus.FSUtil();
    cmd.deselect = false;

    cmd.RunCommand('Set UTILITY=otherlog');
    DOpus.ClearOutput();
    DOpus.Output('Enumerating...\n');

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        if (!item.InGroup('Archives')) continue;

        var folderEnum = fsu.ReadDir(item);
        var folderItem = folderEnum.Next();
        if (folderItem.is_dir && folderEnum.complete) {
            var cmdLine = 'Copy FILE="' + item + '" HERE WHENEXISTS=rename EXTRACT';
        } else {
            var cmdLine = 'Copy FILE="' + item + '" HERE WHENEXISTS=rename EXTRACT=sub';
        }
        DOpus.Output(cmdLine);
        cmd.RunCommand(cmdLine);
    }
    DOpus.Output('\n... done.');
}

36313.dcf (1.9 KB)


4 Likes