Re: Original item in Finder
Re: Original item in Finder
- Subject: Re: Original item in Finder
- From: Adam Wuellner <email@hidden>
- Date: Tue, 30 Aug 2005 15:05:08 -0500
On 8/30/05, Jay Louvion <email@hidden> wrote:
>
> Can someone show me how "original item" is used ?
> The following returns the most surprising error:
>
> tell application "Finder"
> set folderalias to choose folder
> set thefolder to original item of folderalias
> return thefolder
> end tell
>
> Finder got an error: can't return original item of alias
> "full:path:to:an:exisiting:file"
>
> My point is to get the name of a file or folder pointed to by an alias
> without starting to cut up an alias with ":" text delimiters...
> But I might simply be looking at it the wrong way round.
Others may have already said as much, but I think the point of
confusion here is the dual definitions of 'alias'. Finder has aliases
- those shortcuts to existing files that you create in the Finder by
command-option-dragging a file or folder's icon. Those are the things
of which you can ask for the original item.
But there is another alias, analogous to the one just described but
not the same thing. AppleScript has its own idea of an alias - a
reference, in your code, to a file or folder on disk. It is what is
returned by 'choose folder...', and if you store that alias in your
script's properties or global variables, then it will always point to
that same file or folder regardless of how many times you rename it or
move it (there may be limitations as far as moving the file across the
boundaries of physical devices, but that is beside the current point).
That magic of always pointing to the file that was originally pointed
to despite being moved and renamed is what this type of alias shares
with the Finder's type of alias.
So, once you've got an AppleScript alias to a file/folder, you can
just commence doing stuff to it, and AS will do that stuff to the file
that the alias refers to. There is no need to get the original item
of an AppleScript alias, nor is there any concept of what an original
item of such a thing should be.
Original item is only interesting when you have a Finder alias (which
may appear in your code as an AppleScript alias referring to that
Finder alias!) and you want to operate on the actual file/folder that
the Finder alias is linked to.
Gary's examples are completely on target as far as how to get the
information you desire from the alias you've got.
Hope that helps,
Adam
_______________________________________________
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