With the following script is there a faster way to do the repeat function? It's slow with folders of 2500 items.
(* set_Label_Index - 10/23/05 *)
-- NOTE: THIS SCRIPT MAY DEPEND ON THE SATIMAGE.OSAX
tell application "Finder"
set lionBugFixWin to make new Finder window -- Christopher Stone's Lion Bug Fix
close lionBugFixWin
try -- don't crash if nothing selected
set {selected_Items} to selection -- as alias list
end try
set theColorList to {"0-None", "1-Orange", "2-Red", "3-Yellow", "4-Blue", "5-Purple", "6-Green", "7-Gray"}
set selected_Items to selection -- as alias list
if selection = {} then -- there is no item(s) selected
tell me to activate
beep
set buttonReturned to display dialog "No selection was made." & return & "Do you wish to set ALL items to the same color?" as string buttons {"Yes", "No"} default button 1
set buttonReturned to button returned of buttonReturned
if buttonReturned = "Yes" then
tell application "System Events" to keystroke "a" using {command down} -- select all items
set selected_Items to selection -- get label index of first item
set colorchoice to (label index of item 1 of selected_Items) + 1 -- match different counting scheme
else
display dialog "User Cancelled" giving up after 1
return
end if
else if selection ≠ {} then -- there is an item(s) selected
set colorchoice to (label index of item 1 of selected_Items) + 1 -- match different counting schemes
end if
set theDefaultChoice to text item colorchoice of theColorList
-- get color selected
set theChoice to choose from list theColorList default items theDefaultChoice with title "Color Selection (set_Label_Index)" with prompt ("Use ENTER key to accept." & return & "Then press Option key down quickly to select entire folder.")
if theChoice is false then -- if theChoice is false (nothing selected) then return -- "User canceled."
return
end if
delay 1
set modKeys to do shell script (quoted form of "/Library/Application Support/getkeys")
if modKeys contains "option" then
set optionKeyDown to true as boolean
else
set optionKeyDown to false
end if
repeat with i from 1 to number of items in theColorList
if item i of theColorList is in theChoice then
set myLabelIndex to i - 1 -- match different counting schemes
exit repeat
end if
end repeat
if optionKeyDown then
set the label index of the front window's items to myLabelIndex
else
repeat with eachItem in (selected_Items)
set the label index of eachItem to myLabelIndex
end repeat
end if
select {} -- deselect selection(s), exit with nothing selected
beep
end tell