iTunes Metadata Script

Discuss Max, an open source CD audio extractor and audio converter.
Post Reply
Posts: 5
Joined: Sat Apr 26, 2008 11:30 am

iTunes Metadata Script

Post by woZa »

Great little script. Just one issue I have found...

With a compilation cd, the artist of the cd is set to the artist of the first track rather than the cd artist reported by iTunes (generally "Various Artists").

I have had a fiddle with the script but (knowing nothing about scripting!) couldn't get it to make that small change...

No big deal but just a heads up.


Posts: 23
Joined: Sun May 13, 2007 9:58 pm

Re: iTunes Metadata Script

Post by neil.baldwin »

I made this change to the script for the same reason, though you still need to be vigilant as I've found quite a few CDs that have been incorrectly tagged as compilations (in iTunes) and so this will get passed down to Max. If you look from the bottom up you'll see the bit of code - look for the line : 'set artist of maxdisk to "Compilations" : of course you can change it to whatever you like.

Something else to note, I also changed the script so that when it runs, all the tracks on the CD are selected (by default all tracks are unselected) - saves a mouse click :)

Modified script is attached to this message. Just to clarify, this modified script will

- change the disc artist of a compilation CD to "Compilations"
- on completion, set all tracks of the disc to be selected


Code: Select all

tell application "iTunes"
	set foundCD to true
		set myCD to some source whose kind is audio CD
	on error errorMessage number errorNumber
		-- error 1728 means the AudioCD was not found, so wait a little 
		if errorNumber is -1728 then
			set foundCD to false
			display dialog errorMessage
		end if
	end try
	if foundCD then
		set CDname to myCD's name
		set myPlaylist to playlist 1 of myCD
		set theTracks to tracks of myPlaylist
		tell application "Max"
			set mc to (count every track of document 1)
			set maxdisk to document 1
		end tell
		set ic to (count theTracks)
		if mc = ic then
			repeat with i from 1 to (count theTracks)
				set atrack to item i of theTracks
				set ar to artist of atrack
				set al to album of atrack
				set tn to track number of atrack
				set tc to track count of atrack
				set ge to genre of atrack
				set co to composer of atrack
				set ye to year of atrack
				set na to name of atrack
				set comp to compilation of atrack
				set com to comment of atrack
				set dn to disc number of atrack
				set dc to disc count of atrack
				tell application "Max"
					set maxtrack to track i of document 1
					if not (rip in progress of maxtrack) and not (encode in progress of maxtrack) then
						set title of maxtrack to na
						set artist of maxtrack to ar
						set date of maxtrack to ye as string
						set genre of maxtrack to ge
						set composer of maxtrack to co
						set selected of maxtrack to true
						--set number of maxtrack to tn
					end if
				end tell
				if i = 1 then
					tell application "Max"
						set title of maxdisk to al
						-- set artist of maxdisk to ar
						set compilation of maxdisk to comp
						if (comp) then
							set artist of maxdisk to "Compilations"
							set artist of maxdisk to ar
						end if
						set genre of maxdisk to ge
						set date of maxdisk to ye as string
						set composer of maxdisk to com
						-- set track count of maxdisk to tc
						-- max doesn't allow setting total tracks
						set composer of maxdisk to co
						if dn > 1 then
							set disc number of maxdisk to dn
							set total discs of maxdisk to dc
						end if
					end tell
				end if
			end repeat
			display dialog "The iTunes CD track count and the Max CD track count do not match."
		end if
		display dialog "Couldn't get a CD from iTunes. Please retry."
	end if
end tell

Post Reply