I have an iPod. It stores 20Gb of music. I also have about 80Gb of music on my hard drive. All I want is a way to put certain select music on the iPod, and then fill the rest with random music selected from that hard drive. Ok, as an added complication, the hard drive lives on a Linux box, and is NFS mounted on the Mac that drives the iPod. That shouldn’t matter, should it? It’s a fast network link (100Mbps) and goes through a switch instead of a hub.
Ok, first I downloaded some scripts from Doug’s AppleScripts for iTunes. The scripts that I downloaded (“Random Albums to iPod”, “Random Artist to iPod”, “Random iPod”) want to clean out everything else from your iPod first, although if you’re careful you can tell it not to. Not sure if it’s the NFS thing, but the scripts keep timing out after only partly filling the iPod. And then I have to do it again and again until the iPod is reasonably filled.
Ok, I thought, what I need to do is make the playlists ahead of time, and then use the ability of iTunes to sync certain playlists with the iPod.
So I grabbed another script from that site that promises to make random playlists. However, it crashes iTunes every time I tried it. So I did a search and found that version 2.0 of that script is a separate application, so I downloaded it and ran it. I left it running overnight, and in the morning it still said “Importing Library” or some damn thing, and no progress meter. So I killed that.
So now I’m getting desparate. I think I’m just going to sort the library by album and then just shovel the first quarter into one playlist, the second quarter into another playlist, etc.
I make no promises, but this works on my systems. Needs to be configured, first three lines, should be self-explanatory.
set Library_Playlist to “Library” –name of main library
(* should be possible to use “library playlist” but iTunes seems to choke on that *)
set Target_Playlist to “iPod” –name of playlist to sync to iPod
set Target_Size to 25 –size in MB you want to move to iPod
set Target_Size to (Target_Size * 1024 * 1024) –size in bytes
tell application “iTunes”
repeat while (size of playlist “iPod”) is less than Target_Size
set Upper_Limit to number of tracks in playlist Library_Playlist
set Track_Number to random number from 1 to Upper_Limit
set New_Track to track Track_Number of playlist Library_Playlist
copy New_Track to end of playlist Target_Playlist
end repeat
end tell
I was doing this for a while. Create a playlist or two with the stuff you want to keep on the iPod, then a smart playlist which weeds out whatever things you don’t want included (e.g., old audiobooks) and limits the size to suit.
Then tell iTunes to manage the iPod itself, syncing those playlists.
That worked nicely for me. I keep my music on a CIFS share rather than NFS, but the same issues should apply in either case.
Or, if you want to add random albums, try this script. Again, I make no promises, but it seems to work for me.
—-
(*
Paul’s iPod playlist
Finds the start of an album in the Library, copies the whole album to the playlist
Stops when the playlist reaches a defined size
Depends on albums in the Library being contiguous!
*)
set Library_Playlist to “Ian’s iTunes” –name of main library
(* should be possible to use “library playlist” but iTunes seems to choke on that *)
set Target_Playlist to “Random” –name of playlist to sync to iPod
set Target_Size to 25 –size in MB you want to move to iPod
set Album_List to {}
set Target_Size to (Target_Size * 1024 * 1024) –size in bytes
tell application “iTunes”
repeat while (size of playlist Target_Playlist) is less than Target_Size
set Upper_Limit to number of tracks in playlist Library_Playlist
set Track_Number to random number from 1 to Upper_Limit
set this_track to track Track_Number of playlist Library_Playlist
set the shuffle of playlist Library_Playlist to false
set New_Index to index of this_track
if New_Index is not 1 then
repeat while album of this_track is album of (track (New_Index – 1) of playlist Library_Playlist)
set this_track to track (New_Index – 1) of playlist Library_Playlist
set New_Index to index of this_track
if New_Index is 1 then exit repeat
end repeat –having set this_track to the beginning of an album
end if
–don’t repeat albums
if not (Album_List contains (album of this_track)) then
copy (album of this_track) to end of Album_List
repeat while (album of this_track) is (album of (track (New_Index + 1) of playlist Library_Playlist)) –walk through the album
copy this_track to end of playlist Target_Playlist
set this_track to track (New_Index + 1) of playlist Library_Playlist
set New_Index to index of this_track
end repeat
end if
end repeat
end tell
—-
(Although I notice it will finish the album before testing for size, meaning that it might overrun the size limit by up to one album-size.)
‘Hem. The previous version actually adds all but the last track of an album. If you care, I think this should fix it …
—
(*
Paul’s iPod playlist
Finds the start of an album in the Library, copies the whole album to the playlist
Stops when the playlist reaches a defined size
Depends on albums in the Library being contiguous!
*)
set Library_Playlist to “Ian’s iTunes” –name of main library
(* should be possible to use “library playlist” but iTunes seems to choke on that *)
set Target_Playlist to “Random” –name of playlist to sync to iPod
set Target_Size to 25 –size in MB you want to move to iPod
set Album_List to {}
set Target_Size to (Target_Size * 1024 * 1024) –size in bytes
tell application “iTunes”
repeat while (size of playlist Target_Playlist) is less than Target_Size
set Upper_Limit to number of tracks in playlist Library_Playlist
set Track_Number to random number from 1 to Upper_Limit
set this_track to track Track_Number of playlist Library_Playlist
set the shuffle of playlist Library_Playlist to false
set New_Index to index of this_track
if New_Index is not 1 then
repeat while album of this_track is album of (track (New_Index – 1) of playlist Library_Playlist)
set this_track to track (New_Index – 1) of playlist Library_Playlist
set New_Index to index of this_track
if New_Index is 1 then exit repeat
end repeat –having set this_track to the beginning of an album
end if
–don’t repeat albums
if not (Album_List contains (album of this_track)) then
copy (album of this_track) to end of Album_List
copy this_track to end of playlist Target_Playlist
repeat while (album of this_track) is (album of (track (New_Index + 1) of playlist Library_Playlist)) –walk through the album
set this_track to track (New_Index + 1) of playlist Library_Playlist
copy this_track to end of playlist Target_Playlist
set New_Index to index of this_track
end repeat
end if
end repeat
end tell
—