I finally have a button which performs as desired.
However, it runs runs an MS-DOS Batch Function which, in turn, runs a Rexx script since REXX is the scripting language with which I'm most familiar. I'm guessing use of Rexx may make this not of general interest.
I'm using the value of {file} being equal to or not equal to the value of {file|ext} to determine what type of rename to do.
I could, instead, base this decision on whether or not the file is actually a directory, but already having the values of {file} and {file|ext}, basing the decision on those is simpler and adequate for normal cases. Either method can have theoretical problems with unusual cases such as directories with extensions or non-directories without extensions.
My script uses "dopusrt.exe /cmd" to invoke Copy DUPLICATE WHENEXISTS=rename AS commands.
In order to make this work I had to turn off Preferences -> File Operations -> Options -> Deselect files used in functions.
With this preference in effect, apparently the selected file had been deselected bdfore the COPY command ran and the COPY command didn't do anything. At least I guess that's what happened.
Leaving the preference in effect and selecting Postpone file deselection until end of function wasn't sufficient to get the function to do anything..
I don't yet know if I will discover anything I don't like about not having Deselect files used in functions in effect.
Here is my script for anybody who may be interested:
trace ?o
ProgramFiles = strip(value('ProgramFiles',,'ENVIRONMENT'))
DopusPath = '"'ProgramFiles'\Directory Opus'
parse arg file
if substr(file,1,1) = '"'
then parse arg '"' file '"' '"' noext '"' '"' ext '"'
else parse arg file noext ext
date = date('S')
time = time('N')
time = substr(time,1,2) || substr(time,4,2) || substr(time,7,2)
if file = ext
then '"'DopusPath'\dopusrt.exe"' '/cmd',
'Copy DUPLICATE WHENEXISTS=rename AS "'file'_'date'_'time'"'
else '"'DopusPath'\dopusrt.exe"' '/cmd',
'Copy DUPLICATE WHENEXISTS=rename AS "'noext'_'date'_'time || ext'"'