Skip to content

Instantly share code, notes, and snippets.

@alexeypegov
Created September 10, 2010 14:33
Show Gist options
  • Save alexeypegov/573733 to your computer and use it in GitHub Desktop.
Save alexeypegov/573733 to your computer and use it in GitHub Desktop.
Folder action to copy files from this folder to "Automatically Add to iTunes" folder
property extension_list : {"mp3"}
property destination_folder : (path to music folder as text) & "iTunes:iTunes Music:Automatically Add to iTunes:"
property this_action_path : (path to home folder as text) & "Library:Scripts:Folder Action Scripts:copy_to_itunes.scpt"
on adding folder items to this_folder after receiving added_items
set number_of_items to 0
repeat with i from 1 to number of items in added_items
set this_file to item i of added_items
if folder of (info for this_file) is true then
tell application "System Events"
attach action to this_file using this_action_path
end tell
end if
set the item_info to the info for this_file
if (the name extension of the item_info is in the extension_list) then
tell application "Finder" to duplicate this_file to folder destination_folder
set number_of_items to number_of_items + 1
end if
end repeat
if number_of_items is not 0 then
try
tell application "GrowlHelperApp"
register as application "Copy to iTunes" all notifications {"Copied to iTunes"} default notifications {"Copied to iTunes"} icon of application "iTunes"
notify with name "Copied to iTunes" title "Copied to iTunes" description ((number of items in added_items as text) & " file(s) were topied to iTunes") application name "Copy to iTunes"
end tell
end try
end if
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment