property type_list : {"MPG3", "MIDI", "AIFF"} property extension_list : {"mp3", "mid", "aif", "wav", "m4a"} global counter, source_folder, selection_list, these_items tell application "Finder" activate try set the source_folder to (folder of the front window) as alias on error -- no open folder windows set the source_folder to path to desktop folder as alias end try set selection_list to get selection as list set these_items to selection_list end tell if (count of these_items) is greater than 0 then --process items set counter to 0 repeat with i from 1 to (count of items) of these_items set this_item to item i of these_items as alias set the item_info to info for this_item if folder of the item_info is true then process_folder(this_item as alias) else if (alias of the item_info is false) and ((the file type of the item_info is in the type_list) or the name extension of the item_info is in the extension_list) then process_item(this_item as alias) end if end repeat --Deletes original selection tell application "Finder" to delete selection_list display dialog (the counter as string) & " items have been added to the iTunes library. The original files have been deleted." buttons {"¥"} default button 1 giving up after 3 else display dialog "No items selected" end if -- this sub-routine processes folders on process_folder(this_folder) set these_items to list folder this_folder without invisibles repeat with i from 1 to the count of these_items set this_itemPath to this_folder & (item i of these_items) as string set this_item to this_itemPath as alias set the item_info to info for alias this_itemPath if folder of the item_info is true then process_folder(this_item) else if (alias of the item_info is false) and  ((the file type of the item_info is in the type_list) or  the name extension of the item_info is in the extension_list) then process_item(this_item) end if end repeat end process_folder -- this sub-routine processes files on process_item(this_item) tell application "iTunes" launch add this_item to playlist "Library" of source "Library" end tell set counter to counter + 1 end process_item