Skip to content

Instantly share code, notes, and snippets.

@dhiraj
Last active April 24, 2018 19:30
Show Gist options
  • Save dhiraj/5093759 to your computer and use it in GitHub Desktop.
Save dhiraj/5093759 to your computer and use it in GitHub Desktop.
This AppleScript may allow you to remove or set the album rating on one or more of your tracks to a value you decide. If you use Smart Playlists based on the track rating field, this may be *the* AppleScript you were looking for. If not, then consider moving on, this is probably not what you were looking for. I've modified the script in this fil…
(*
"Album Rating Reset" for iTunes
written by Doug Adams
[email protected]
v1.0 sept 6 2007
-- initial release
v2.0 mar 6 2013
updated by Dhiraj Gupta (http://www.dhirajgupta.com)
-- added support for multiple track selection. *Please* note, I'm a first time AppleScript author, there might be glaring omissions, stupidity and other forms of chaos. But it *did* work for me, so there! :)
Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
or visit http://www.gnu.org/copyleft/gpl.html
*)
property star : («data utxt2605» as Unicode text)
property blankstar : («data utxt2606» as Unicode text)
property halfstar : («data utxt00BD» as Unicode text)
property tabs1 : (tab)
property tabs2 : (tab & tab)
property tabs3 : (tab & tab & tab)
property tabs4 : (tab & tab & tab & tab)
property my_title : "Album Rating Reset"
tell application "iTunes"
if selection is {} then
display dialog "Please select at least one track. Please select only music tracks, not albums."
else
set target_rating to my get_number("")
repeat with this_track in selection
set the_actual_track to contents of this_track
try
set album rating of the_actual_track to target_rating
on error the the_errormessage number the the_errornumber
display dialog "Error: " & the_errornumber & ". " & the_errormessage buttons {"Cancel"} default button 1 with icon 2 giving up after 15
end try
end repeat
end if
end tell
to get_number(addenda)
set rez to text returned of (display dialog addenda & "Enter value for Album Rating from the list below:" & return & return & tabs1 & blankstar & " = 0 (computed)" & tabs1 & halfstar & " = 10" & return & ¬
tabs1 & star & " = 20" & tabs4 & star & halfstar & " = 30" & return & ¬
tabs1 & star & star & " = 40" & tabs3 & star & star & halfstar & " = 50" & return & ¬
tabs1 & star & star & star & " = 60" & tabs3 & star & star & star & halfstar & " = 70" & return & ¬
tabs1 & star & star & star & star & " = 80" & tabs2 & star & star & star & star & halfstar & " = 90" & return & ¬
tabs1 & star & star & star & star & star & ¬
" = 100" default answer "" with title my_title)
try
set rez to (rez as number)
if rez ≤ 100 then
if rez mod 10 = 0 then
return rez
else
get_number("")
end if
else
get_number("")
end if
on error
get_number("Enter a number..." & return & return)
end try
end get_number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment