Oops. I knew I should have asked
That copy-and-rename is indeed a bit trickier.
Try
// https://resource.dopus.com/t/copying-and-renaming-a-file-adding-creation-modified-date/47181
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
cmd.deselect = false;
var dest = tab.path + '\\! bu';
cmd.RunCommand('CreateFolder NAME="' + dest + '" READAUTO=dual,nofocus');
cmd.SetDest(dest);
for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {
var item = e.item();
var cmdLine = 'Copy' +
' FILE="' + item + '"' +
' AS="' + item.modify.Format('D#yyyy.MM.dd, T#HH.mm.ss') + ' ' + item.name + '"' +
' WHENEXISTS=skip';
// DOpus.Output(cmdLine);
cmd.RunCommand(cmdLine);
}
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="label" hotkey_label="yes" label_pos="right" textcol="none">
<label>47181</label>
<tip>copying-and-renaming-a-file-adding-creation-modified-date</tip>
<icon1>#script</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>// https://resource.dopus.com/t/copying-and-renaming-a-file-adding-creation-modified-date/47181</instruction>
<instruction />
<instruction>function OnClick(clickData) {</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> var tab = clickData.func.sourcetab;</instruction>
<instruction />
<instruction> cmd.deselect = false;</instruction>
<instruction />
<instruction> var dest = tab.path + '\\! bu';</instruction>
<instruction />
<instruction> cmd.RunCommand('CreateFolder NAME="' + dest + '" READAUTO=dual,nofocus');</instruction>
<instruction> cmd.SetDest(dest);</instruction>
<instruction />
<instruction> for (var e = new Enumerator(tab.selected); !e.atEnd(); e.moveNext()) {</instruction>
<instruction> var item = e.item();</instruction>
<instruction />
<instruction> var cmdLine = 'Copy' +</instruction>
<instruction> ' FILE="' + item + '"' +</instruction>
<instruction> ' AS="' + item.modify.Format('D#yyyy.MM.dd, T#HH.mm.ss') + ' ' + item.name + '"' +</instruction>
<instruction> ' WHENEXISTS=skip';</instruction>
<instruction />
<instruction> // DOpus.Output(cmdLine);</instruction>
<instruction> cmd.RunCommand(cmdLine);</instruction>
<instruction> }</instruction>
<instruction>}</instruction>
</function>
</button>