I need a script to read every .dwg/.step in a selected folder and its subfolders then proceed to a sequence of clicks to save the files on the same folder then close it.
Here is what I have, Applescripts doesn't recognize the .dwg/.step extension instruction.
set MyFolder to (choose folder)
tell application "Finder"
set MyFiles to every file of entire contents of MyFolder whose name extension is ("DWG" or "STEP")
return MyFiles -- this doesn't return anything
repeat with aFile in MyFiles
tell application "Rhinoceros"
open aFile
activate
delay 1
end tell
tell application "System Events" -- the instruction is given 'manually'
click at {150, 1}
delay 1
click at {150, 180}
delay 1
click at {680, 335}
delay 1
click at {600, 495}
delay 1
click at {900, 510}
end tell
delay 1
end repeat
end tell
I'm a beginner with applescript but this application would save tons of hours of work! Thanks in advance for your help :)
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:although Finder does let you combine these predicates into a list upon which it can operate collectively:
Also, move your final
end tell
to the just after declaring yourMyFiles
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:
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 asave
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 menusave
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
(ormove
) the files to a new location:or
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: