Actually, StefanK’s script seems to require no manual setup.
Hi Mike,
That’s right. It’s your choice what to do. I was just suggesting a different way for speed. When I tried sorting earlier, it was very slow. I didn’t make timing tests, but it seems to me that iTunes could sort it faster. After all, it sorts the whole library very quickly.
gl,
Hi.
This version doesn’t do a full sort, but gets the highest track applicable track number and tries all the numbers from 0 to there. It’s quite fast on my machine, but I suspect that might depend on the size of your playlist library.
Script edited after unconscious assumptions noticed in the original. :rolleyes:
on showError(msg)
tell application (path to frontmost application as Unicode text)
display dialog msg buttons "Cancel" default button 1 with icon stop
end tell
error number -128
end showError
tell application "iTunes"
activate
if (player state is in {playing, paused}) then
set {cur_artist, cur_album} to current track's {artist, album}
if ((count cur_album) is 0) then my showError("This track has no album!")
set trackNumbers to track number of tracks of library playlist 1 whose album is cur_album and artist is cur_artist
set max to item 1 of trackNumbers
repeat with i from 2 to (count trackNumbers)
if (item i of trackNumbers > max) then set max to item i of trackNumbers
end repeat
--if (max > 0) then
if (playlist "Current Album" exists) then delete playlist "Current Album" -- with all its settings.
set albumPlaylist to (make new playlist with properties {name:"Current Album"})
repeat with i from 0 to max
try
duplicate (first track of library playlist 1 whose album is cur_album and artist is cur_artist and track number is i) to albumPlaylist
end try
end repeat
set view of browser window 1 to albumPlaylist
play albumPlaylist
--end if
end if
end tell
This assumes, of course, that “Current Album” isn’t one of the user’s own playlist names!