Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Use iTunes search box to search by ratings' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use iTunes search box to search by ratings
Authored by: DougAdams on Mar 15, '04 11:50:37AM
This works on the selected tracks:
tell application "iTunes"
	if selection is not {} then
		set these_tracks to a reference to selection
		set the track_count to the count of these_tracks
		if button returned of (display dialog "There are " & track_count & ¬
			" tracks. Proceed with rating all of them?" buttons {"Don't rate", "Rate"} default button 2) is "Rate" then
			repeat with i from 1 to the track_count
				set this_track to item i of these_tracks
				
				set newRating to {"=", "=", "=", "=", "="}
				set c to 1
				repeat ((rating of this_track) div 20) times
					set item c of (newRating as list) to "*"
					set c to c + 1
				end repeat
				set comment of this_track to newRating as string
			end repeat
		end if
	end if
end tell


[ Reply to This | # ]
Use iTunes search box to search by ratings
Authored by: podd on Mar 19, '04 05:39:43PM
Using Python:

#!/usr/local/bin/pythonw

import re
from appscript import *

for track in app('iTunes.app').selection.get():
	rating = track.rating.get() // 20
	comment = track.comment.get()
	comment = re.sub(' [=*]{5}$', '', comment) # remove existing 'rating', if any
	comment += ' ' + '*****====='[5 - rating:10 - rating] # append new 'rating'
	track.comment.set(comment)
(Requires MacPython 2.3+ and appscript.)

[ Reply to This | # ]