2

I want an applescript to grab the BPM & Star Rating of a selected group of MP3's and paste the info into the comments section.

I found this code that will copy the star rating one track at a time but I do not know applescript well enough to modify it to do a group of selected tracks and also grab the BPM.

tell application "iTunes"
    set theTrack to (item 1 of (get selection))
    set theRating to rating of theTrack
    if theRating = 100 then
        set comment of theTrack to "5 Star"
    else if theRating ≥ 80 then
        set comment of theTrack to "4 Star"
    else if theRating ≥ 60 then
        set comment of theTrack to "3 Star"
    else if theRating ≥ 40 then
        set comment of theTrack to "2 Star"
    else if theRating ≥ 20 then
        set comment of theTrack to "1 Star"
    else if theRating = 0 then
        set comment of theTrack to "0 Star"
    end if
end tell
1
  • I actually figured out how to edit a script to get the BPM. Now I just need to make this script able to edit a selection. – Bless Oct 17 '15 at 13:56
1

You want to grab the selection, which will be a list of tracks. Then, you use a repeat block to process each track in the list. Here's the script. You may want to adds checks to make sure iTunes is running, and some try blocks in case of failures:

tell application "iTunes"
    set selectedTracks to selection
    repeat with thisTrack in selectedTracks
        set theRating to rating of thisTrack
        set theBPM to bpm of thisTrack
        set theComment to "" & (theRating / 20 as integer) & " star | BPM: " & theBPM
        set comment of thisTrack to theComment
    end repeat
end tell

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .