Addressing files without all the object palaver
Addressing files without all the object palaver
- Subject: Addressing files without all the object palaver
- From: Timothy Bates <email@hidden>
- Date: Fri, 18 Jan 2002 13:24:40 +1100
On 18/1/02 4:49 AM, "A A" <email@hidden> wrote:
>
Is there a way to define a path in AS without sounding
>
like the Old Testament?
>
>
Something like: "drive/folder/file"
>
>
instead of:
>
'And lo-and-behold, "Drive" begat "Folder-A" who
>
begat "Folder-B" who begat "File" and then the
>
Mennonites ... :-D
Yes. It is only the finder (because files are objects to it) that wants to
treat file paths as object containment hierarchies
So: no one but the finder understands the "a of b of c of d" form, and in
the finder you can always convert to and from this by using names like alias
and string.
"file A of disk b" as string --> "b:A"
"file A of disk b" as alias --> alias "b:A"
You can ask the finder for the contents of a folder as "alias list"
tell application "Finder"
every file of (folder choose folder) as alias list
-->{alias "Cortex:Users:tim:file1",alias "Cortex:Users:tim:file1"}
end tell
(beware that this foolish coercion returns an error if there is only 1 item
as it refuses to make a 1-item list. Don't ask why.)
tim