Applescript to Heart or Love or Favorite song
This is the script I use. It toggles the loved status of the current track.
tell application &quot;iTunes&quot;
    if loved of current track is true then
        set loved of current track to false
    else
        set loved of current track to true
    end if
end tell

It also works for Apple Music; just replace &quot;iTunes&quot; with &quot;Music&quot;.