These commands don't mix too well in a command button. You are better off with a script like this:
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
var fsu = DOpus.FSUtil();
cmd.deselect = false;
var extensions = DOpus.Create().StringSetI('.jpg', '.bmp', '.png', '.gif', '.webm');
cmd.ClearFiles();
var folderEnum = fsu.ReadDir(tab.path, 'r'); // recursive
while (!folderEnum.complete) {
var folderItem = folderEnum.Next();
if (folderItem.is_dir) continue;
if (!extensions.exists(folderItem.ext)) continue;
cmd.AddFile(folderItem);
}
cmd.RunCommand('Image CONVERT=jpg QUALITY=90 WIDTH=500 PRESERVEASPECTRATIO HERE REPLACE ADDSUFFIX "_thumb"');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>37535</label>
<icon1>#newcommand</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>function OnClick(clickData) {</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> var tab = clickData.func.sourcetab;</instruction>
<instruction> var fsu = DOpus.FSUtil();</instruction>
<instruction> cmd.deselect = false;</instruction>
<instruction />
<instruction> var extensions = DOpus.Create().StringSetI('.jpg', '.bmp', '.png', '.gif', '.webm');</instruction>
<instruction />
<instruction> cmd.ClearFiles();</instruction>
<instruction> var folderEnum = fsu.ReadDir(tab.path, 'r'); // recursive</instruction>
<instruction> while (!folderEnum.complete) {</instruction>
<instruction> var folderItem = folderEnum.Next();</instruction>
<instruction> if (folderItem.is_dir) continue;</instruction>
<instruction> if (!extensions.exists(folderItem.ext)) continue;</instruction>
<instruction> cmd.AddFile(folderItem);</instruction>
<instruction> }</instruction>
<instruction> cmd.RunCommand('Image CONVERT=jpg QUALITY=90 WIDTH=500 PRESERVEASPECTRATIO HERE REPLACE ADDSUFFIX "_thumb"');</instruction>
<instruction>}</instruction>
</function>
</button>