Re: Getting finder Labels?
Re: Getting finder Labels?
- Subject: Re: Getting finder Labels?
- From: email@hidden
- Date: Thu, 8 Nov 2001 23:42:18 -0500
On Tue, 6 Nov 2001 16:17:19 -0800 (PST), Brian Johnson <email@hidden>
asked,
>
What is the appropriate method by which to get the text string of the
>
Finder's "Label" fields for a file? I looked in the Finder's dictionary
>
and tried telling the finder to
>
>
set x to label name of (choose file)
>
>
but that doesn't work.
>
>
set x to label index of (choose file)
>
>
works, but I'd like to get the text string rather than the index.
>
Suggestions?
If you look at the Finder's dictionary, you'll see that, while "label index" is
a property of a file, the table that relates index numbers to names is the
"label" elements of the "Finder preferences" of the application. So, you need
something like this:
tell application "Finder"
set x to label index of (choose file)
set x to name of label x of Finder preferences
end tell
If you want it compact, the expression could be,
tell application "Finder"
set x to name of label (label index of (choose file)) of Finder
preferences
end tell
But one warning: there is no label 0. So if the chosen file has no label
(index=0), you get "Can't get label 0 of Finder preferences." So you'll
probably want to first get the index, check it against zero, and translate
non-zero labels via the table.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden