The Copy command can rename files, but it is not as powerful as the Rename command. So we let a script take care of this. The button will work on all selected files.
// https: //resource.dopus.com/t/file-copy-trim-and-add-current-date/39902
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
cmd.deselect = false;
// cmd.RunCommand('Set UTILITY=otherlog');
// DOpus.ClearOutput();
var currDate = DOpus.Create().Date().Format('D#yyMMdd');
for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
var item = e.item();
var cmdLine = 'Copy DUPLICATE AS="' + item.name_stem.replace(/\d\d\d\d\d\d$/, currDate) + item.ext + '"';
// DOpus.Output(cmdLine);
cmd.RunCommand(cmdLine);
}
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
<label>39902</label>
<icon1>#newcommand</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>// https: //resource.dopus.com/t/file-copy-trim-and-add-current-date/39902</instruction>
<instruction />
<instruction>function OnClick(clickData) {</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> var tab = clickData.func.sourcetab;</instruction>
<instruction> cmd.deselect = false;</instruction>
<instruction />
<instruction> // cmd.RunCommand('Set UTILITY=otherlog');</instruction>
<instruction> // DOpus.ClearOutput();</instruction>
<instruction />
<instruction> var currDate = DOpus.Create().Date().Format('D#yyMMdd');</instruction>
<instruction />
<instruction> for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {</instruction>
<instruction> var item = e.item();</instruction>
<instruction> var cmdLine = 'Copy DUPLICATE AS="' + item.name_stem.replace(/\d\d\d\d\d\d$/, currDate) + item.ext + '"';</instruction>
<instruction> // DOpus.Output(cmdLine);</instruction>
<instruction> cmd.RunCommand(cmdLine);</instruction>
<instruction> }</instruction>
<instruction>}</instruction>
</function>
</button>
Please read, if you haven't already: