Help with copy command, distguish between file and directory

Directories don't have file extensions. You can't associate programs (etc.) with directories based on their extensions; their type is always "directory". If there's a dot in a directory's name it has no special meaning. So that part is right, IMO.

Not sure what {file|ext} should do with a file that has no extension... probably either return an empty string, or abort the command, or skip that file (maybe depending on whether it's {file$|ext} or {file|ext} i.e. need or want).

Empty string would be good for rename scripts that are just trying to preserve the extension, where an empty string would be valid. It'd cause problems in other situations where an extension was needed, though... Probably still gets my vote.

I know I only talked about {file|ext}, but, If I accept that argument, then it seems that the whole name, "." and all, should be returned by {file|noext}.

Doesn't seem to make sense to "have it both ways".

Agreed.

I've made a summary of the file/folder extension stuff showing what it does now and what I feel it should do:

leo.dopus.com/reports/Opus_Extensions.png

(Or in Excel 2007 format if you want to be able to copy & paste the commands: leo.dopus.com/reports/Opus_Extensions.zip )

Before I submit that to GPSoftware, does anyone see anything they disagree with or that I've missed?

Update: As rcoleman1943 says below, these changes were made in Opus 9.1.3.0 so the ext/noext stuff works much better now.

Here's my current version of a button, the desire for which started this whole thread (make a copy of a file with a timestamp appended to the filename):

And here is the script invoked by the button:

This is simpler than my previous version and relies only on the value of {file}, not using either {file|ext} or {file|noext}.

In all cases it simply splits the entire filename at the (last) dot putting that dot and anything following it after the timestamp and everything else before the timestamp. If there is no dot, everything goes before the timestamp.

Based on recent discussion, I realize the desirability of this behavior may be questionable in the case of a directory name containing a dot, but it's very simple and probably adequate for my use in real life situations (which probably don't include directory names containing a dot anyway).

I could probably modify this to handle directory names differently if anyone cared.

(To care would require having a REXX interpreter installed and any change I might make might require a specific REXX interpreter).

As of Opus 9.1.3.0, it's possible to do what the original poster wanted to do with both directories and (non-directory) files using the following code for a key or button

@nofilenamequoting Copy DUPLICATE WHENEXISTS=rename AS "{file|noext}_{date|yyyyMMdd}_{time|HHmmss}{file|ext}"