Random Album to iPod

I posted this on the iPodLounge forum but thought I’d post here as well in hopes of getting a more varied approach to solving my problem.

Please choose the appropriate forum for this topic. Thank you. I share the same displeasure as several others about the lack of a Random Album option in iTunes and have written a script for it. Mine behaves different than others in that it doesn’t require your iPod to be set up for manual update, just that you have an appropriately named Playlist that’s set to automatically update.

I have a working version, but until I am pleased, I’m hesitant to post it to Dougs AppleScripts for itunes. My reasoning is the time it takes to run. I have a decent version, but it takes 15 minutes. In my attempts to trim down the time by using a dynamic list of albums, it bumped up the time to almost an hour! I’d really like to get the time down using dynamic lists, because the other method has (what would appear on the surface to be) a very easily solved flaw.

The problems are thus:

These are approximate codes and are supplied as conceptual as I don’t have the script with me. My apologies.

set name of album of current track to album_name
	if album_name is not in album_list then
		copy (all tracks in playlist "temporary" whose album is album_name) to playlist "Pack the 'Pod"
		set end of album_list to album_name
	end if

The above code uses a list of all albums chosen to prevent duplicate albums from being moved to the appropriate playlist and thus throwing off the capacity. (The capacity, by the way, is a variable which can be set to any size you like at launch time, every time). The problem with this approach is when the library becomes more than ~75% chosen. Naturally, iTunes is then drawing more and more albums which have already been chosen in its attempt to find the few remaining. My solution was to create a temporary playlist and have it draw from that deleting tracks as it went. The above code was altered thusly:

set name of album of current track to album_name
copy (all tracks in playlist "temporary" whose album is album_name) to playlist "Pack the 'Pod"
delete (all tracks in playlist "temporary" whose album is album_name)

This code fails because the delete command aparently bogs down iTunes causing the time to completion to skyrocket up to an hour! (for 23 gigs of music).

If anyone has suggestions for improvements on either of these two approaches, I would greatly appreciate it.