Watch folder for MP3, Edit ID3 Tags, Move to New Folder

I’m very new to AppleScript and I’m not quite sure if this is even possible, but if it IS, it would make my life so much easier! Here’s what I’m trying to do:

  1. Watch my “/Users/johns/Downloads” folder for new files
  2. If a new MP3 file is detected, it will automatically edit the ID3 tags for Artist and Album Artist to “Artist Name” and Album to “Album Title”
  3. After these ID3 tags are edited, it will move this file to “/Users/johns/Music/iTunes/iTunes Media/Automatically Add To iTunes” folder

It sounds simple when I write it out like that but I’m sure it’s anything but that… I’d really love some help on this. Thank you so much!!!

Edit: Bonus Points! I’d love to be able to change the Title on the ID3 tag of the MP3 as well, while appending the date to it. So the title would be changed to “Show Title -DATE HERE-” - is something like that possible?

A Folder Action attached to your Downloads folder could work.

Maybe best to let iTunes take care of the ID3 Tag stuff. There are lots of example Applescripts at http://dougscripts.com/itunes/ that do this sorta thing…

The following Folder Action script will get you started…

Rather than use “Automatically Add To iTunes” folder it temporarily moves mp3 (& aac) files only from Downloads to Unknown Artist folder, then tells iTunes to briefly play each track so they are copied to their correct folders (you MUST have iTunes preference “Copy files to iTunes Media folder when adding to library” & “Keep iTunes Media folder organised” checked!!), then adds the tracks to “Downloads” playlist.

The next stage is to perform ID3 actions on each track in the playlist… (beyond my scope I’m afraid)

Google if you’re not sure how to set up a Folder Action for your Downloads folder…

(*
"import to iTunes from Downloads test"

This Folder Action handler is triggered whenever items are added to the attached folder. 
Place in ~/Library/Scripts/Folder Action Scripts
Attach to ~/Downloads folder with the Folder Actions Setup Utility

iTunes Preference MUST have "Copy files to iTunes Media folder when adding to library" & "Keep iTunes Media folder organised" checked.
*)

on adding folder items to this_folder after receiving added_items
	
	--set up...
	set path2home to (path to home folder) as text
	set iTunesMusicFolder to (path2home & "Music:iTunes:iTunes Music:") as text
	set UnknownAlbumFolder to iTunesMusicFolder & "Unknown Artist:Unknown Album:" as text
	set playlistName to "Downloads"
	set myExtensions to {"mp3", "m4a"}
	set MyTrackList to {}
	
	--move added items to Unknown Album Folder
	try
		tell application "Finder"
			repeat with i from 1 to count of added_items
				if name extension of item i of added_items is in myExtensions then
					move item i of added_items to folder UnknownAlbumFolder
				end if
			end repeat
		end tell
	on error the error_message number the error_number
		display dialog "Error: " & the error_number & ". " & the error_message buttons {"Cancel"} default button 1 with icon 0
	end try
	
	--make playlist
	tell application "iTunes"
		activate
		if (not (exists playlist playlistName)) then
			make new playlist with properties {name:playlistName}
		end if
		set the view of the front browser window to playlist playlistName
		repeat with i from 1 to (count of added_items)
			
			--import to iTunes
			try
				open (item i of added_items)
			end try
			--add to playlist
			set theTrack to current track
			set TrackName to name of theTrack
			set MyTrackList to MyTrackList & TrackName
			duplicate theTrack to playlist playlistName
			stop
		end repeat
		
		--report
		set MyTrackListText to ""
		repeat with i from 1 to (count of MyTrackList)
			set MyTrackListText to MyTrackListText & "\"" & item i of MyTrackList & "\" "
		end repeat
		activate
		display dialog "Imported track(s): " & MyTrackListText buttons {"OK"} default button 1 with icon 1
		
		--***NOW PERFORM ID3 ACTIONS ON TRACKS IN PLAYLIST "DOWNLOADS"! check out "http://dougscripts.com/itunes/" ***
		
	end tell
	
end adding folder items to