Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

After reconsolidating my music collection in iTunes, I’m curious if there is any way to programmatically set star ratings based upon the number of plays, but only for songs that I have not yet rated?

Specifically, I'd like to set all songs with >1 plays and 0 stars, to 3 stars.

(3 being the average in that I didn't care enough to rate the song lower because I hated it, higher because I liked it, because I was doing something else at the time.)

An AppleScript that I can run occasionally would be sufficient – this way I can passively set song ratings based upon an apathetic impression of the song :).

share|improve this question
1  
If you'd like to create your own Applescript, this is a great place to start: dougscripts.com/itunes. He doesn't have anything that does exactly what you need, but if you're familiar with Applescript, it shouldn't be too hard to roll your own. –  Vickash Nov 10 '11 at 18:57
    
@Vickash Interesting, I think this site has examples that describe nearly every component that I need... I'll have a look around! If I can construct a completed solution, i'll post it here. Thanks! –  adamrmcd Nov 10 '11 at 19:13
add comment

1 Answer 1

up vote 3 down vote accepted

Create a smart playlist in iTunes with criteria set to all of

  • is Music
  • rated less than 1 star
  • play count greater than whatever count you want

Check “update automatically”. Make sure the contents conform to the list of songs you want to rate automatically. Name it “Unrated Songs” (or similar).

Now create the following AppleScript:

tell application "iTunes"
    set unratedSongs to tracks in (playlist "Unrated Songs")
    repeat with unratedSong in unratedSongs
        set rating of unratedSong to 60
    end repeat
end tell

Save it to ~/Library/Scripts/Applications/iTunes (creating the folders that do not exist yet – note ~/Library is hidden under Lion: use the Finder’s “Go To” menu while pressing Option to get to it or press Cmd+Shift+. in the Save dialog to show hidden folders) as “Rate unrated songs”. You will find the script in iTunes’ script menu, ready to do your bidding.

share|improve this answer
    
Why the AppleScript? Once you have created the playlist, select all songs in it and select Rating in the File menu to set the number of stars you want. –  patrix Nov 10 '11 at 20:24
    
@patrix: the script spares you the step of going to the smart playlist and selecting everything – a minor convenience, but one step closer to automatical processing. –  kopischke Nov 10 '11 at 20:34
    
Why 60? Does that map to 3 stars somehow? Is it 20 points per star? Is it useful to have ratings at one point intervals (i.e. rating of 58)? –  Bill Nace Nov 10 '11 at 20:47
1  
@BillNace: internally, ratings are stored as value from 0 to 100 – stars map to 20 point increments. iTunes will round other ratings to the nearest star (or half star, if you enable that). –  kopischke Nov 10 '11 at 20:49
    
PERFECT!! I implemented your script as an hourly cronjob, rather than run it manually in iTunes, and set the value to 50. By creating a another smart playlist, "Autorated Songs", which shows files that were greater than 2 stars and less than 3 stars, I can see which files were auto-rated without eating up a 3-star rating. Thanks!! –  adamrmcd Nov 10 '11 at 21:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.