Your main problem is the use of the or
operator inside parenthesis which is being performed on two string values. This doesn't make sense to AppleScript, nor should it. The correct expression would be:
...whose name extension is "DWG" or name extension is "STEP"
although Finder does let you combine these predicates into a list upon which it can operate collectively:
...whose name extension is in {"DWG", "STEP"}
Also, move your final end tell
to the just after declaring your MyFiles
variable—there's no need (and it's actively obstructive) to enclose the System Events operations inside the Finder block.
Thus your Finder command should end up looking something like:
tell application "Finder" to set MyFiles to (every file of the entire contents of ¬
(choose folder) whose name extension is in {"DWG", "STEP"}) as alias list
I've coerced it to an alias list
at the end there because it'll speed up the processing time, for some inexplicable reason.
The last part of your script is something I can't provide too much insight into without knowing more about this application "Rhinoceros". I did a quick Google, but couldn't find anything.
But if it's able to understand the open
command, that implies it's scriptable and it probably has a save
command that goes along with it.
NEVER try and accomplish things by clicking at coordinates—it'll break with the slightest pin drop. If the program isn't scriptable, it'll probably throw an error with the open
command, in which case your best bet is to script its application process and access the menu save
command.
But I think you're going to have a tough time implementing this successfully, whichever way you go.
HOWEVER, if all you want is, as you stated, to save those files inside a single folder, then you needn't try and use Rhinoceros at all. Instead, use Finder to duplicate
(or move
) the files to a new location:
tell app "Finder" to duplicate MyFiles to MyFolder
or
tell app "Finder" to move MyFiles to MyFolder
This can all be condensed into a single line, so your entire script (if this is what you indeed want the outcome to be) would simply become:
set myfolder to (choose folder)
tell application "Finder" to move (every file of the entire contents of myfolder ¬
whose name extension is in {"DWG", "STEP"}) as alias list to myfolder