Wed Oct 15 9:41 AM
All articles

How to rate a song in Apple Music with AppleScript

November 4, 2026

A star rating in Music is one number on the song, and a script can read and set it. There is one catch: a song that is not in your library refuses the write. Here is the scale, the script, and the error

The scale

The property is rating, and it runs from 0 to 100. One star is 20, so 1 star is 20, 2 is 40, 3 is 60, 4 is 80 and 5 is 100. In our library, the only values we found were 0, 20, 40, 60, 80 and 100. Apple describes the same one-to-five-star range in its guide to rating songs

Rate the current song

tell application "Music"
  set rating of current track to 80
end tell

That is four stars. Read it back with get rating of current track. Setting 0 clears the stars

Rating kind

Every song also has rating kind. It is user when the stars came from you and computed when Music worked the value out itself. In our tests, a write of 0 put the kind back to computed. If you only want to know whether you rated a song, check that the kind is user, not that the number is above zero

Why you get error -54

Error -54 is "File permission error". A script gets it when it sets rating on a song that is not in your library. A song you favorited from the catalog without adding it lives only in Favorite Songs: in our test library, 375 of 471 favorites were not in the library. The Music window can rate such a song by hand, but a script cannot, even when the song already has stars

Check before you write:

tell application "Music"
  set pid to persistent ID of current track
  if (count of (every track of library playlist 1 whose persistent ID is pid)) is 0 then
    return "Not in the library"
  end if
  set rating of current track to 80
end tell

What does not help

  • Duplicating the song into the library list. duplicate current track to playlist 1 runs without an error and the count of the library list goes up, but the new entry has no date added, and the rating still fails with -54
  • Setting the album rating. It changes the computed value of the song, and rating still returns -54

We did not test radio stations, so we do not say what a rating does there. The fix for a catalog song is to add it to the library first: adding it in the Music window does it, and Likeit does it for you as part of rating, see how to rate a song that is not in your library

Tested on

macOS 15.7 with a current Music. A different macOS version can behave differently, so try a song from your own library first

Likeit sets the same rating from the menu bar: one Rate shortcut and a digit from 0 to 5

All articles