Hi all,
I have been dealing with issues of OS X 10.8.2 and iFlicks not working on downloaded video files. I am trying to have a script launch iFlicks and handle it differently depending on the file extension. I have tried the multitude of readily available scripts to no avail. So I have pared it down to a basic script, as follows:
global anyVar
on adding folder items to thisFolder after receiving theItems
set anyVar to name extension of theItems
tell application "Finder"
display dialog anyVar
end tell
end adding folder items to
The above does not work. Yes, it is attached to the folder I am adding files to, and Folder Actions are enabled. I have also tried it without declaring anyVar as a global variable.
If I try this script:
on adding folder items to thisFolder after receiving theItems
tell application "Finder"
display dialog "Hello world!!"
end tell
end adding folder items to
It works, about 3-5 seconds after adding files to the test folder. The issue appears to be caused when I try o utilize the name extension index. I am using OS X 10.8.2 on a Mac Mini. Does anyone see the issue here??!?
Name extension is an property of an file object of application “finder”, you can’t use it outside the tell application block.
Ok, I tried the following:
global anyVar
on adding folder items to thisFolder after receiving theItems
tell application "Finder"
set anyVar to name extension of theItems
display dialog anyVar
end tell
end adding folder items to
and still no success…
Basically you can, if the object is really a Finder file specifier.
name extension is defined also in the info for record of Standard Additions, so the terminology (aka the four-letter token) is established.
But in this case indeed you can’t because the class of each received item is alias specifier and only the Finder and System Events can access file properties of an alias.
What all the above means for digitalbuddha (welcome to MacScripter) is:
on adding folder items to thisFolder after receiving theItems
-- Iterate through the list of added items.
-- (It's still a list, even when there's only one item.)
repeat with thisItem in theItems
tell application "Finder"
-- Use the Finder to extract the name extension of each individual item.
set anyVar to name extension of thisItem
display dialog anyVar
end tell
end repeat
end adding folder items to
That did it!! Thank you so much for the help!!