Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Broken AppleScript in Lion (“can’t get container of file”)

I’m excerpting from a script that used to work well in SL but is now broken in Lion:


tell application "BBEdit"

set theOriginalFile to file of document 1

tell application "Finder"

set c to get container of theOriginalFile

return c

end tell

end tell


It used to return the path to the document, but now it generates an error: “Finder got an error: Can’t get container of file [path to the file].”


It’s not clear what the problem is. Also, it would be great if Apple (or someone) could compile a list of things that break in AppleScript under Lion and how to fix them.

MacBook Pro, Mac OS X (10.7)

Posted on Aug 3, 2011 8:38 AM

Reply
Question marked as Best reply

Posted on Aug 3, 2011 9:44 AM

Does it work if you replace

set c to get container of theOriginalFile

with

set c to get container of file theOriginalFile

?

2 replies

Aug 3, 2011 9:49 AM in response to Pierre L.

Yes, it does, Pierre! Thanks! That’s one of many alterations I did not try.


So, Lion AppleScript appears to have changed something about how references work? The variable “theOriginalFile” was created as a reference to a file, so that should be embedded in the variable itself without needing the class to be specified explicitly.


Thank you!

Broken AppleScript in Lion (“can’t get container of file”)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.