iTunes script -- copy/rename current song..

Hello. I’ve searched high and low for a script that will do this, with no luck.

I want iTunes (4) to copy the current song to a specified folder, and rename the file to match iTunes display (artist - title).

Is this possible?

/tommy

This works for me…

tell application "iTunes"
	set theTitle to name of current track
	set theArtist to artist of current track
	set songLocation to location of current track as string
end tell
set finalFolder to (choose folder) as string
set theLength to count of characters in songLocation
set theExt to characters (theLength - 2) through theLength of songLocation
set finalName to theArtist & " - " & theTitle & "." & theExt
tell application "Finder"
	set newSongFile to duplicate alias songLocation to folder finalFolder
	set name of newSongFile to finalName
end tell

Does that work for you?

-RJ

Thanks very much RJ! …and yes, it ALMOST does! it copies the renamed song to the selected folder, but only after I load the script each time. It doesn’t copy them automatcially as the songs change.

/tommy

Hmmm… I don’t know how to make it so that it copies the songs as they change. Instead I modified the previous script allowing you to select as many songs as you’d like and then doing what the other script did to each one, instead of doing just the currently playing song. I don’t know if that would help you or not, but here it is:

set finalFolder to (choose folder) as string
tell application "iTunes"
	set allTracks to selection
	if allTracks is {} then display dialog "You didn't select any tracks!" buttons {"Cancel"} default button 1
	repeat with i in allTracks
		set theTitle to name of i as string
		set theArtist to artist of i as string
		set songLocation to location of i as string
		tell application "Finder"
			set theLength to count of characters in songLocation
			set theExt to characters (theLength - 2) through theLength of songLocation
			set finalName to theArtist & " - " & theTitle & "." & theExt
			set newSongFile to duplicate alias songLocation to folder finalFolder
			set name of newSongFile to finalName
		end tell
	end repeat
end tell
display dialog "Done!" buttons {"OK"} default button 1

Is that more like what it was you needed?

-RJ