Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to copy iPod ratings back to iTunes Apps
I recently moved from the US to the UK, and brought my iPod with me. I got a new computer, and so I copied my music from my iPod to iTunes (since I wanted all the songs, I just used cp -R from the hidden iPod_Control folder to my Music folder). Unfortunately, this does not copy things like ratings, comments, play count, etc.

Thus I created the following AppleScript...

Enter the following in Script Editor, then save it to your Scripts folder...
tell application "iTunes"
  set trackList to get selection
  
  repeat with sourceTrack in trackList
    set sourceData to (get {name, artist, album} of sourceTrack)
    set copyData to (get {played date, played count, rating} ¬
      of sourceTrack)
    set addSourceData to (get {time, size, year, bit rate} ¬
      of sourceTrack)
    
    set trackList to (every track of playlist "Library" whose ¬
      ((name is item 1 of sourceData) ¬
      and (artist is item 2 of sourceData) ¬
      and (album is item 3 of sourceData) ¬
      and (time is item 1 of addSourceData) ¬
      and (size is item 2 of addSourceData) ¬
      and (year is item 3 of addSourceData) ¬
      and (bit rate is item 4 of addSourceData)))
    
    repeat with destTrack in trackList
      if (item 1 of copyData is not equal to missing value) then
        set played date of destTrack to item 1 of copyData
      end if
      if (item 2 of copyData is not equal to missing value) then
        set played count of destTrack to item 2 of copyData
      end if
      set rating of destTrack to item 3 of copyData
    end repeat
  end repeat
end tell
Basically, you navigate to your (manually updated) iPod inside of iTunes, select the tracks from which you want to copy ratings, played count, and last played for, and the script finds the corresponding track in your library and copies the data. In fact, it also works from shared music as well (assuming you have the exact same song file as the sharer).

If you want anything besides these three fields (I left out enabled, comment, volume adjustment, EQ, start, finish, and modification date), add the field name to the list of field names defining copyData, and also set the field name in the final repeat, noting that I had trouble when a field had a value of "missing value."

I got the idea and method for this script from a program called Synch iPod-iTunes Data, but it was unreliable for me, and would only copy data for songs that had a last play date.
    •    
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[20,063 views]  

An AppleScript to copy iPod ratings back to iTunes | 3 comments | Create New Account
Click here to return to the 'An AppleScript to copy iPod ratings back to iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to copy iPod ratings back to iTunes
Authored by: dfbills on Oct 28, '04 02:53:21PM

I needed something similar and worked with Doug Adams to create:

Tags to Get Info Comments (and Back)

http://www.malcolmadams.com/itunes/scripts/ss.php?sp=tagstogetinfocomments


This does exactly what you'd expect:

Two scripts to store, and then later retrieve, tags to a track's file's "Get Info" comments. Optionally, you can also store the Playlist names the track appears in, and later restore the track to those playlists which will be recreated if necessary. Supports MP3, AAC, AIFF, and WAV track/files.
• Requires iTunes 4.1 or better.
• These scripts improve on a set of scripts called "Restore Library 2-Step". Those scripts cannot work with anything but MP3 files.

---

-d



[ Reply to This | # ]
An AppleScript to copy iPod ratings back to iTunes
Authored by: mclaugh on Oct 29, '04 01:59:57PM

I'm in the process of moving my 30k song library from Windows to Mac- well, actually, I just want to move the rating and play count info over, as the files won't be moved.
I already make good use of the comments field, using it to store certain keywords that I reference in my smartlists. So, I've been in the process of using two fields that I usually leave blank- grouping and bpm.
I created six smartlists for rating, 0 through 5. I then selected all the tracks in each list, and changed the bpm field accordingly (all the tracks that had three stars appear in the 3 smartlist, and have "3" in their bpm field now, for example.)
While tedious, I'm also creating a series of smartlists for play count (0-26 at last check). I then put the play count into the grouping field.
My plan on my powerbook is to import all my files, and create those same smartlists. Once I've done that, I'll use one of Malcom Adams' applescripts to change the playcounts. Rating is even easier- I'll just create a smartlist that groups by bpm, and then assign all those files the appropriate rating.
Anyone else have a better idea?



[ Reply to This | # ]
An AppleScript to copy iPod ratings back to iTunes
Authored by: mollw on Oct 30, '04 08:48:26AM

I don't know if it's "better" but I've got a few scripts to backup rating and playlist info to the comments field and also some to add keywords to the groupings field.

For ratings the main script puts "®®100®®" for 5 star "®®080®®" for 4 star etc songs at the beginning of the comments field. I've got a smart list for all rated songs and periodically run the script on all the tracks in it. In fact more recently I've written scripts to rate the currently playing song 1 to 5 star which also update the comments field at the same time and I invoke these by hot keys so the song is rated at the press of a button.

For playlists there's a script to put the name of the playlists a song is in in the comments (after the rating) as '§§playlist whatever§§".

Then there are a few scripts to add keywords to the grouping field. I pick the keywords from a picklist for a whole group of songs to reflect mood, main instrument etc. (e.g. sax, piano, mellow, dance etc). If a song already has some keywords they are highlighted by default in the picklist. I also have a few scripts invoked by hotkey to add a particular keyword to the currently playing song.

Oh dear it all sounds very complicated, but actually it isn't. Basically it means everything (ratings, playlists and keywords) is backed up to the track's id3 tag in a way which is platform independent. It also means I can rate a track or give it a keyword to reflect its mood/instrument etc on the fly.

If you want the scripts I can post them.

m



[ Reply to This | # ]