I’m a newbie to AppleScript but I’m familiar with many other languages. At the moment I’m writing a script to batch convert WMF (and other vector files) into SWF via Illustrator CS. This is my first AppleScript… (a hack of a number of other scripts)
So far the conversion works fine, but I want to be able to recursively traverse sub-folders. I’m probably doing a lot of things wrong (or incorrectly).
The actual code that is causing me hassle is this:
tell application “Finder”
if (the kind of myFinderItem is “Folder”) then
Each time, Folder is highlighted and the following error comes up:
System Events got an error: NSCannotCreateScriptCommandError
Is it a syntax issue or could it be down to the rest of my script? If anyone could help I would really appreciate it, I intend to post this on this site when it is finished (and the code is cleaned up).
This is my boilerplate recursion scheme, although I’m sure many veterans can improve on this. (My personal conventions are to precede text string variable names with “t”, aliases with “a”, and put an “L” at the end of list names, if that helps explain this.)
set saveDelims to text item delimiters
set text item delimiters to ":"
traverse(path to startup disk)
set text item delimiters to saveDelims
set itemL to list folder a without invisibles
set tPath to ((text items 1 through -2 of (a as text)) as text) & ":"
repeat with tItem in itemL
set aFilespec to alias (tPath & tItem)
if folder of (get info for aFilespec) then
display dialog "process " & aFilespec as text