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

Click here to return to the 'Properly sort 'Album by Year' in iTunes and devices' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Properly sort 'Album by Year' in iTunes and devices
Authored by: davechevell on Apr 30, '10 06:43:49AM

Just because I'm bored, reincorporated the GUI (now displays time taken to run).. had to move a couple of things around but it still achieves the effect of the original script:

tell application "iTunes"
set startTime to (get current date)
set oldfi to fixed indexing
set fixed indexing to true
set cnt to 0
if selection is not {} then
set sel to selection
display dialog "Update Sort Album" & return & return & "Adds year to the beginning of the \"Sort Album\" tag. This helps iPods, iPhones and iPads sort Albums by Year." & return & return buttons {"Cancel", "Continue"} default button 1 giving up after 30

repeat with this_track in sel
if this_track's sort album does not contain this_track's artist & " - " & this_track's year then
set this_year to this_track's year as string
set this_artist to this_track's artist
if word 1 of this_artist is "a" or word 1 of this_artist is "the" then set this_artist to text ((offset of " " in this_artist) + 1) thru -1 of this_artist
set this_album to this_track's album
if word 1 of this_album is "a" or word 1 of this_album is "the" then set this_album to text ((offset of " " in this_album) + 1) thru -1 of this_album
set this_track's sort album to this_artist & " - " & this_year & " - " & this_album
set cnt to cnt + 1
end try
end if
end repeat

display dialog "Select some tracks first..." buttons {"Cancel"} default button 1 with icon 2 giving up after 30
end if
set fixed indexing to oldfi
set endTime to (get current date)
set process_duration to endTime - startTime
set mins to process_duration div minutes
set secs to process_duration mod minutes

display dialog "Done!" & return & return & (cnt & " track(s) updated.") & return & "Process took " & mins & " minutes and " & secs & " seconds." & return buttons {"Done"} default button 1 with icon 1 giving up after 15

end tell

[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: Lrwebb on Apr 23, '12 10:07:18AM

I know this thread is a couple of years old but I just wanted to thank josh and Dave for making this script.

I've been looking for a script like this for ages and this does just the job I was looking for. Almost. In fact, I've set about making a couple of edits for it to fit my requirements more exactly.

One, I always set the sort artist tag to last name, first name so I want the artist in the sort album tag to reflect this. I am a scripting novice but I've just managed to get that one to work.

Two, I would like to check to see if this track is part of a compilation. If true, then set artist to Various Artists. Perhaps even preceed that with some char to force compilations to the bottom of the albums list.

Thanks again guys.

[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: Calion on Aug 01, '13 02:28:42PM

So post your modified version then! We want to see what fixes you made.

I agree though, the script is excellent. Thanks to Dave for his modified script.

[ Reply to This | # ]