Re: Original item in Finder
Re: Original item in Finder
- Subject: Re: Original item in Finder
- From: "Gary (Lists)" <email@hidden>
- Date: Tue, 30 Aug 2005 06:39:38 -0400
"Shane Stanley" wrote:
> On 30/8/05 8:15 PM, "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.
>
> Original item is for use with alias files, as in aliases made manually in
> the Finder using File -> Make Alias -- it returns the file or folder that
> the alias was made from. I suspect that what you're after is the
> "container".
Actually, it looks more like Jay wanted to get the name of the object at the
end of the path, the file or folder.
The term he used I think you cleared up, Shane.
Jay, when you write "cut up an alias with ":" text delimiters, it's pretty
clear that you mean you have something that looks like:
alias "SuperBadMama:folder:folder:file.txt"
You want that last item, right?
That's easiest to get my saying:
set myName to name of (get info for alias "SuperBadMama:...")
In practice, you usually have that in a variable, and you may want more
information than just the name, so it's good to do it in one fell swoop:
set theFileObject to alias "SuperBadMama:folder:folder:file.txt"
set itemInfo to info for theFileObject
set itemName to name of itemInfo
That said, you should go ahead and get familiar with 'text item delimiters'
because they are very useful for any number of scripting tasks, and you
_will_ need to use them at some point.
In order to highlight further the difference between a "Finder alias" and an
AppleScript alias type, in the script above, you can also add this line, at
the end:
set isAlias to alias of itemInfo
If 'isAlias' is true, then you have on your hand a real-life Finder alias,
and you _may_ then wish to get the source of that Finder alias. That is
when you use the 'original item of' construction you started with.
I hope that helps.
--
Gary
_______________________________________________
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