Request: Applescript for random albums on ipod shuffle

I don’t know if requests are allowed here, but i’ve been trying to figure this out on my own, but i don’t know applescript… (or at least not enough for this…)

I have an iPod Shuffle and i like it, but i’m someone who likes to listen full albums. So i was dissapointed to see that there is a random tracks feature in iTunes, but not a random albums feature. Now i have a playlist where i manually put in my albums, but i like it to be automated and fully random. So i thought that an applescript was the best way to accomplish that.

So my question is: is anyone willing to help me with such a script? Or has anyone already made something like that?

Thanks in advance…

I am not going to test this, since I have a huge iTunes library (and I don’t want hundreds of new playlists), but it should work:

set all_albums to {}
tell application "iTunes"
	repeat with an_album in (album of every track in playlist 1)
		set current_album to (an_album as string)
		if all_albums does not contain current_album then
			set end of all_albums to current_album
			make new user playlist with properties {name:current_album}
			duplicate (every track whose album = current_album) to user playlist current_album
		end if
	end repeat
end tell

What it does is to make a new playlist for each album in the library, and fill it with every track from each respective album. Is that what you are looking for?

Thanks Craig Smith, but it’s not what i’m looking for.

I want 1 playlist, witch will be randomly filled with albums. Let’s say until the playlist is larger than 950 mb. So if i’m thinking correctly applescript will have to do this:

  • Check if the playlist (let’s call it “ipod shuffle playlist”) excists
  • If it does empty it
  • If it doesn’ create it
  • Pick a random artist from the main library
  • See if the artist has multiple albums
  • If so it has to pick a random album (or else go to the next step)
  • Copy all the songs in that album to the specified playlist
  • Check the size of the playlist
  • If it’s smaller than 950 mb execute the script again
  • If it’s larger, than stop.

So i have it all thought out, but i’m such a applescript that i don’t even know how it has to pick a random item…

:wink: :confused:

I just posted a script that does something similar for my iPod Nano. Check it out and we’ll see what it takes to amend it for your purposes: http://bbs.applescript.net/viewtopic.php?id=19820

Wow that does what i need! thank you!

now an other question: how to update my ipod, because i just use “update” (fond it in this forum) is updates the ipod, but doesn’t updates the songs…

Glad the script works for you, I was hoping someone besides me would get some use from it!

By “update” do you mean “sync?” I’m not being a smart-aleck, there’s a difference between saving the play/skip counts back to iTunes and changing the songs on the iPod.

By default, iTunes should update everything automatically without ANY scripts. The exception to that is if, like me, you want to copy whole albums to the iPod and need to run a script to create the playlist you want. But syncing/updating is built into iTunes and doesn’t need a script to run. Some older versions of iTunes (version 4 and earlier) needed a program called iSync, but all that’s built into iTunes now.

I’ve got a Nano (which is a bit different than a shuffle) and since most of my playlists are set up to pull the “least recently played” songs, that moves the songs that were just listened to off the iPod and moves songs that haven’t been listened to in a while to the iPod.

At the same time, the play/skip counts get updated, too. I would try just plugging in the shuffle and letting iTunes update/sync and then see if it holds what you want it to.

You can also mount the iPod without updating/syncing by holding down the option and cmd keys while plugging in the iPod (iTunes needs to already be open, or it will think you want to start iTunes with a different music library). I sometimes do that if I want to see what’s on the Nano BEFORE I sync to it. Then I can make changes and select “Sync iPod” from the “File” menu or I can right click the iPod and select “sync.”

Try walking me through a “normal” update on your iPod, and I’ll have a better idea what you need.

Well what i mean by updating (maybe that was the wrong term) is getting the files in my fresh made playlist to my iPod. I thought that “update” would do that, but that’s not so.

I’ve tried a few scripts that i found on this site and dougscripts.com that directly copy the files to the ipod’s library (not through itunes), but they don’t work, and my ipod gets confused and i have to restore it :S

so can i ony do this manually(not that i mind doing that, but it would be nice if it all goes automatically wouldn’t it?) or is there an applescript action for that “autofill” button?

OK, I think I see what you’re getting at. You can use the Autofill button two ways: you can let it randomly pick tunes to put in your shuffle or you can set the Autofill button to load the shuffle from the playlist(s) you choose.

What I do with the Nano is this: I update the Core Albums playlist when the Nano is NOT docked, (like just before I sync it). Then when I get the playlist how I want it, I plug the iPod in and it syncs automatically.

So if you always use the same playlist NAME for your syncs, you can change the CONTENTS of that playlist when the iPod is not connected, then let it sync automatically when you dock the shuffle.

That make sense?

Brining up an old thread but have just got a shuffle myself and having the same probs as the OP. Kevin’s script seems like it would be perfect, but am using Windows… apols for noobie question, but is there any way I can use the script he gave on my Windows 7 machine?

Thanks