tell application "Finder"
set thisItem to selection as alias
if label index of thisItem = 0 then
set the label index of thisItem to 2 --label value, 0 is no label
else
set label index of thisItem to 0
end if
end tell
Basically, it turns on and off a label (in this case, label “2”) on the selected item via Butler. (http://www.manytricks.com/butler/)
But I realized that it lacked an important feature: it only handles one file at a time.
I’m an Applescript amateur and I’ve picked up a lot, but”how can I modify this to handle multiple items?
tell application "Finder"
set ItemList to selection
if not ItemList is {} then
repeat with thisItem in ItemList
if label index of thisItem is in {0, 2} then
set the label index of thisItem to 2
else
set label index of thisItem to 0
end if
end repeat
end if
end tell
I guess if it already label 2 you want to keep it label 2.
I’ll have a play with Butler as it looks interesting as it triggers Applescripts
I also figured out (via the applescript pre-builts under the contextual menu)
tell application "Finder"
set these_items to the selection
end tell
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
tell application "Finder"
if label index of this_item = 0 then
set the label index of this_item to 2 --label value, 0 is no label
else
set label index of this_item to 0
end if
end tell
end repeat
.but your seems to run faster than this way.
Also, the code toggles the label bit on and off.
Thanks for that code, as I think now I see how to set it up for the array of labels.