Re: tutorial on HFS versus finder and POSIX file path ?
Re: tutorial on HFS versus finder and POSIX file path ?
- Subject: Re: tutorial on HFS versus finder and POSIX file path ?
- From: Timothy Bates <email@hidden>
- Date: Tue, 17 Oct 2006 18:15:25 +0100
- Thread-topic: tutorial on HFS versus finder and POSIX file path ?
>> i'm new to as and more or less lost with the different way to
>> represent a file path :
>> the finder one, the HFS one and POSIX one.
Finder files objects which contain other objects
File "Yvon" of folder "Appscript" of folder "apple lists" of disk "apple"
Everything else apart from Finder thinks of file paths as single objects, of
type alias or type string and consisting of a colon delimitted
concatenation of containers terminated by a target:
set thePath to "apple:apple lists:Appscript:Yvon" as string
You can coerce a string to an alias:
set thealias to alias "apple:apple lists:Appscript:Yvon"
And vise versa:
set thePath to thealias as string
A gotcha here is not to add the object name to something that is already an
object, i.e., "alias thealias" will fail as it will try to make an alias
out of an alias, which is a meta object that does not exist.
The final form is posix (slash delimitted or unix) formats.
If you want to use posix-style file specs you say
posix file "apple/apple lists/Appscript/Yvon"
If you want to get the posix style form from an HFS form, you say
posix path (file "apple:apple lists:Appscript:Yvon")
You can run into problems with going back and forth between HFS and posix.
While posix ALLOWS spaces in file names, the shell (you are probably using
posix in oder to send a shell command with do shell script) treats spaces an
the delimtter of arguments to commands. So you need to escape characters
that are illegal.
set theAlias to alias "Prelude:Users:tim:Desktop:2 puzzle.piece.eps"
quoted form of POSIX path of theAlias
"'/Users/tim/Desktop/2 puzzle.piece.eps'"
FYI, I mostly do is keep everything as a string, even in the Finder.
That said, the Finder object-form has the benefit of being able to
understand messages like "container of finderPath"
Standard Additions has a nice universally available command "file
information"
File information of alias the alias
--> All kinds of stuff like name, displayed name, status etc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden