How to script playing a specific iTunes playlist in a specific folder?

Hi,

I have playlists with the same name in different playlist folders in iTunes and I would like to be able to script playing a specific iTunes playlist in a specific folder. At the moment iTunes defaults to playing the first playlist it finds with the name, and that’s it. I have tried using a combination of playlist and folder playlist in a script, but can’t get it work. Is this possible? Perhaps by getting the id of the playlist? If so, I’m not sure how to do this, and would be glad of some help.

Thanks,

Nick

Mmmh, I played a bit more with the id idea and came up with this, which seems to work:

tell application "iTunes"
	set targetPlaylist to "4"
	set myFolder to folder playlist "ratings"
	
	set myPlaylists to playlists
	repeat with aPlaylist in myPlaylists
		try
			if aPlaylist's parent = myFolder and aPlaylist's name = targetPlaylist then
				copy id of aPlaylist to the_id
				play user playlist id the_id
			end if
		end try
	end repeat
	
end tell

Not sure if it’s fullproof, or the most efficient method though!