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

Properly sort 'Album by Year' in iTunes and devices Apps
I use iTunes in list view, and also use the column browser (at the top) in order to quickly jump to the music I want to hear. My music albums are sorted by Album by Year (click the Album column header), like most people with many albums, I guess.

Here's my problem: When I jump to Cover Flow view mode, and when using the column browser, albums are sorted alphabetically. I have the same problem on my iPhone. I found out how to override that strange behaviour: I simply copied album's release year into the Sort Album field of the sorting tab.

With this value set, the albums sort properly in all view modes, and in the column browser. Unfortunately, doing this by hand is tedious; any script solutions in the comments are appreciated!

[robg adds: I tested this, and it works as described, though I'm not sure if there are downsides to storing the Year value in the Album sort field. A starting point for a script solution might be Doug Adams' This Tag, That Tag Scripts 2.0, though it's not a perfect fit out of the box.]
    •    
  • Currently 2.60 / 5
  You rated: 1 / 5 (15 votes cast)
 
[20,809 views]  

Properly sort 'Album by Year' in iTunes and devices | 12 comments | Create New Account
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: shavenyak on Mar 31, '10 08:25:06AM

I don't use Cover Flow or the column mode much, but I may use a variation on this to fix my pet peeve - multiple albums released in the same year by the same artist. Putting something in the Sort Album field to indicate the correct order of release should work. Thanks for the idea!



[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: isogrifo on Mar 31, '10 09:03:58AM

I've always added a number preceding the album title (eg. 01 Album Name) so they would sort properly. I like this method much better, though if you browse by album on the iPod or AppleTV, it just becomes a jumbled mess.



[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: le_nombril on Mar 31, '10 10:33:00AM

I found both downside and solution:
- The number of albums in the column browser is in fact the number of distinct years, the label being the last album of the that year in alphabetical order and filtering using this column filters on all albums released that year
- The solution is to concatenate year and album title in the Album sort field

Bonus hint: If a band released several album the same year, I add a letter after the year so alphabetical sort is correct (1985a<AlbumName>, 1985b<AlbumName>, etc...)



[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: dfbills on Mar 31, '10 12:00:31PM

I'd be curious to see if this would work in smart playlists on iphone as well.

---
-d



[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: BlaatMekker on Mar 31, '10 01:26:40PM

The downside is that when you browse by album (instead of artist) on your iPhone/iPod Touch all your albums are under the 0-9 header instead of being separated alphabetically.



[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: x5josh5x on Apr 01, '10 06:08:30AM

I wanted the same thing and so wrote this Apple Script a while ago. It's very basic and borrows heavily from others, but it gets the job done. Make sure you have selected some tracks before running it.

(*

"Update Sort Album"
written by Josh Raub
(with code generously borrowed from others)

-- Adds tags of the format "1965 Highway 61 Revisited" in the Sort Album tag. This approximates the "Album By Year" sorting method on the iPod when using CoverFlow

v1.0
-- Initial release
-- It won't ignore the 'A' or 'The' for titles beginning with them, but that only matters if you ever want to sort "Album by Artist"

*)

tell application "iTunes"
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 Cover Flow display as \"Album by Year\" on the iPod." & return & return buttons {"Cancel", "Continue"} default button 1 giving up after 30

set oldfi to fixed indexing
set fixed indexing to true
set cnt to 0

repeat with this_track in sel
try
set this_Year to this_track's year as string
set this_Album to this_track's album
set this_track's sort album to this_Year & " " & this_Album
set cnt to cnt + 1
end try
end repeat

set fixed indexing to oldfi

display dialog "Done!" & return & return & (cnt & " track(s) updated.") & return buttons {"Thanks"} default button 1 with icon 1 giving up after 15
else
display dialog "Select some tracks first..." buttons {"Cancel"} default button 1 with icon 2 giving up after 30
end if
end tell



[ Reply to This | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: davechevell on Apr 30, '10 05:51:42AM

x5josh5x: Your script is EXCELLENT. Just what I needed to get my iPhone to sort albums by year before name.

In the spirit of collaboration, I made a few modifications =)

Notes are for intrepid googlers who find their way here:

1 - Sort Album field is now "Artist - Year - Album". This is because the "Albums" view on my iPhone is otherwise impossible to navigate unless i know the year every album in my library was made, and that nifty alphabet-quick-scroll thingie on the right hand side is completely useless when all Sort Album fields begin with a number

2 - Artists & Albums that begin with "A" or "The" (i.e. The Beatles) have these words stripped from the applied Sort Album field (not case sensitive)

3 - Script tests to see if the desired Sort Album field already exists. Running this script for the first time on a library containing thousands of tracks can take a while - running this script a second time to update new songs in your library will be much quicker (my library is about 4000 items - first time running this took a few minutes; second time took 20 - 25 seconds as it found nothing that needed updating)

I modded it purely to run on my own library, so I removed the GUI actions - running this requires opening in AppleScript editor, pasting this in, selecting the desired iTunes tracks (or hitting &#8984; + a to select all). If you're antsy about this kind of stuff, I advise you select one or two tracks in iTunes, run it on them and check the results. You'll feel more comfortable running this on your entire library afterwards.

Random googlers who have ended up here: Since this modifies every song in your library, syncing your iPhone/iPod/iPad the first time after running this is going to take a while, as it has to copy every track over again. Running this script for the first time is also going to take a few minutes at the very least, depending on the size of your music library.

Anyway, here we go. Apologies about bad formatting.. first post, idiot newbie, etc etc. Please direct posting advice this way, I want to give a little back! Thanks again, x5josh5x





tell application "iTunes"
if selection is not {} then
set sel to selection
repeat with this_track in sel
if this_track's sort album does not contain this_track's artist & " - " & this_track's year then
try
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
end try
end if
end repeat
end if
end tell



[ Reply to This | # ]
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
try
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

else
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 | # ]
Properly sort 'Album by Year' in iTunes and devices
Authored by: le_nombril on Aug 28, '10 01:34:47PM

This method has a huge advantage I discovered today: You can now search music by year in the search field of itunes (in seems not to work in iphone spotlight)



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

This doesn't seem to work with iTunes Match in iOS 6. Can anyone else verify whether this is the case, or if it's just me?



[ Reply to This | # ]