In a freak accident I accidently deleted all of the “of X” information for my iTunes track numbers. For example, instead of seeing “1 of 10”, “2 of 10”, “3 of 10” I now just see 1, 2, 3, etc. Now I could go through all 1147 albums and add that infomation myself or. maybe there’s hope in AppleScript!
I’m wondering if there’s anyway to search through the iTunes Library, look for individual albums, determine how many total tracks there are and automatically add that information to the song data? Is this just a pipe dream or is it possible?
I’m sorry to say that my AppleScript knowledge if quite poor, but I can understand basic programming logic and might be able to figure something out if someone got me started. Any ideas or feedback would be deeply appreciated.
Thanks StefanK! The Albumize Selection script is definitely a help. Basically what it does is look at the play order of the currently selected tracks and adds “of x” to each track number. So this does what I need, but stops after one album. Does anyone know how to tell iTunes to select the next album in the list and then do the same thing again?
Which list? iTunes is organized by playlists, the album property is only a part of each track
so it’s quite difficult to parse the library to extract the albums
The Music playlist in the source list? I’m referring to when you select “Music” from the source list and are in browse view, you can see a list of albums. It says “All (xxx albums)” and then lists each album. It is possible to select an album, run a script and then the script automatically selects the next alphabetical album?
I would say 95% of the tracks on in my library are from whole albums so if I can find or put together a script that does what I explain above then it’s fine with me.
The reason why I posted the question is because you can get artist, album, and track info from Internet by querying a cd database. But first, if you run this, do you get a track count:
tell application "iTunes"
track count of some track of first library playlist
end tell
Hopefully, you won’t get a track you already changed.
Here’s an example of getting info from the internet for the first track in your Lirary playlist:
tell application "iTunes"
set lib_pl to first library playlist
set first_track to first track of lib_pl
set trk_info to {}
set end of trk_info to artist of first_track
set end of trk_info to album of first_track
end tell
set {ar, al} to trk_info
set ar to ReplaceText(ar, space, "+")
set al to ReplaceText(al, space, "+")
set the_url to "http://musicbrainz.org/ws/1/release/?type=xml&artist=" & ¬
ar & "&title=" & al & "&limit=1&inc=counts"
do shell script "curl " & quoted form of the_url
--
on ReplaceText(t, s, r)
set utid to AppleScript's text item delimiters
set AppleScript's text item delimiters to s
set temp_list to text items of t
set AppleScript's text item delimiters to r
set temp_text to temp_list as string
set AppleScript's text item delimiters to utid
return temp_text
end ReplaceText
The result, if it’s in the database, is xml which you can get info from.