Easily combine multiple disc albums in iTunes

From Mac OS X Hints.com http://www.macosxhints.com/

When selecting albums to play, especially on the iPod, where you can only select one thing to play, listening to albums with multiple discs becomes a nuisance - if not an impossibility. Now, combining discs by hand can be tedious, but with the power of applescript, we can do the process quite painlessly. First, lets get the track numbers for the second (and third, and so on) discs in order. For this use the script “Add n to track number,” which I have written and included below. To use it, just select the tracks to be affected and type the amount to add to the track number of each of them.

Now that the track numbers are all in order (notice we intentionally ignored track count), select all the discs and set their album name and track count to the obvious values. Now your tracks are all combined neatly in a single album, as they should be. Ah, so much cleaner!

Note: you can also fool with disc number, if you wish to preserve that information in some form. I choose to ignore it, but it would not be hard to add this to the script. I’m guessing it wouldn’t be that hard to automate the entire process, in fact.

OS version: OS X

tell application "iTunes"
  set theTracks to selection
  if theTracks is not {} then
    display dialog ¬
      "Add this much to each track number:" default answer ¬
      0 buttons ("Do it now!") default button 1
    set theNum to (the text returned of the result as integer)
    
    repeat with i from 1 to count of theTracks
      set theTrack to item i of theTracks
      set the track number of theTrack to ¬
        (the (track number of theTrack) + theNum)
    end repeat
    
  else
    display dialog "You need to select some tracks first."
  end if
end tell