file objects
file objects
- Subject: file objects
- From: Thomas Fischer <email@hidden>
- Date: Sat, 27 Feb 2010 18:41:58 +0100
Hello,
I ran into some problems with file objects and am wondering if I misunderstood something and/or how to treat them correctly (in the background is the problem of the three different ways AppleScript refers to elements of the file system).
I can say
set myFile to alias "Macintosh HD:Examples:03.pdf"
but I get an error for
set myFile to file "Macintosh HD:Examples:03.pdf"
To get a file object, I seem to need an application.
I can try the Finder:
tell application "Finder" to set myFile to file "Macintosh HD:Examples:03.pdf"
--> document file "03.pdf" of folder "Examples" of startup disk
set myClass to class of myFile
--> document file
so this is a "document file", not a file.
Or I can try System Events:
tell application "System Events" to set myFile to file "Macintosh HD:Examples:03.pdf"
--> file "Macintosh HD:Examples:03.pdf"
set myClass to class of myFile
--> file
Or without an application I can use a POSIX path, trusting that "the result of evaluating a POSIX file specifier is a file object":
set myFile to POSIX file "/Examples/03.pdf"
-->file "Macintosh HD:Examples:03.pdf"
set myClass to class of myFile
-->«class furl»
So this is not a file object.
The AppleScript Language Guides claims "AppleScript supports coercion of a file object to a text", but funnily enough, from the above results the file object obtained from System Events is the only one that cannot be coerced to text but gives an error message.
Can anybody illuminate the situation?
Thomas Fischer
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden