Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- property type_list : {"MPG3", "MIDI", "AIFF"}
- property extension_list : {"mp3", "mid", "aif", "wav", "m4a"}
- global numOfItems, all_items, source_folderName, audiofile_list, audioCheckReply, addReply
- on adding folder items to source_folder after receiving these_items
- --process items
- set audiofile_list to {}
- set all_items to these_items
- set numOfItems to ((the count of these_items) as string)
- set source_folderName to name of (info for source_folder)
- 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
- check()
- end adding folder items to
- on process_folder(this_folder)
- set these_items to list folder this_folder without invisibles
- repeat with x from 1 to the count of these_items
- set this_itemPath to this_folder & (item x 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 as alias)
- end if
- end repeat
- end process_folder
- -- this sub-routine processes files
- on process_item(this_item)
- set the end of audiofile_list to (this_item as alias)
- end process_item
- on check()
- if (count of audiofile_list) is greater than 0 then
- with timeout of 4000 seconds
- set audioCheckReply to display dialog "Do you want to add new audio files to iTunes?" buttons {"No", "Yes"} default button "No"
- if button returned of audioCheckReply is "Yes" then
- addFilesToITunes()
- activate
- if ((count of audiofile_list) is equal to 1) and ((count of numOfItems) is equal to 1) then
- set addReply to display dialog "1 new item has been added to the iTunes library. Do you want to delete the 'original'?" buttons {"No", "Delete 'Original'"} default button "No"
- else if (count of audiofile_list) is equal to 1 then
- set addReply to display dialog "1 new item has been added to the iTunes library. Do you want to delete the 'original' or all of the new files that were added to '" & source_folderName & "'?" buttons {"No", "Delete 'Original'", "Delete All New Files"} default button "No"
- else
- set addReply to display dialog ((count of audiofile_list) as string) & " new items have been added to the iTunes library. Do you want to delete the 'originals' or all of the new files that were added to '" & source_folderName & "'?" buttons {"No", "Delete 'Originals'", "Delete All New Files"} default button "No"
- end if
- if (button returned of addReply is equal to "Delete 'Originals'") or (button returned of addReply is equal to "Delete 'Original'") then
- tell application "Finder"
- delete audiofile_list
- end tell
- else if (button returned of addReply is equal to "Delete All New Files") then
- tell application "Finder" to delete all_items
- end if
- end if
- end timeout
- end if
- end check
- on addFilesToITunes()
- tell application "iTunes"
- launch
- add audiofile_list to playlist "Library" of source "Library"
- set lastItem to get end of audiofile_list
- play lastItem
- end tell
- end addFilesToITunes
Advertisement
Add Comment
Please, Sign In to add comment