Re: How to get the names of items in a Finder selection.
Re: How to get the names of items in a Finder selection.
- Subject: Re: How to get the names of items in a Finder selection.
- From: John W Baxter <email@hidden>
- Date: Sun, 24 Dec 2000 16:06:12 -0800
At 12:49 -0800 12/24/00, Michelle Steiner wrote:
>
If you use "the selection" you will get a list containing the full path
>
name of each item in the selection. Then you have to extract the item
>
names from the list.
See below: you can let "Finder" extract the names for you, in the one
command to Finder.
>
>
tell application "Finder"
>
the selection as alias list
>
end tell
>
>
--> {alias "Dora:Graphics:", alias "Dora:Games :", alias
>
"Dora:Documents:", alias "Dora:Installer Logs:"}
>
>
>
Here's a simple way to get a list of only the item names.
>
>
tell application "Finder"
>
activate
>
copy
>
set x to the clipboard
>
end tell
>
>
--> "Documents
>
Games
>
Graphics
>
Installer Logs"
>
Another possibility is
tell application "Finder"
name of items of selection
end tell
which a moment ago correctly returned
{"Drop_PDF", "DropStuff", "Drop*PS", "StuffIt Expander", "Folder Script"}
>
As an added bonus, it alphabetizes the list for you.
Which my suggestion does not. I can see uses for both methods.
--John
--
John Baxter email@hidden Port Ludlow, WA, USA