Re-numerate selected tracks in iTunes

applescriptitunes

I often do the same job: select each track in selected set of tracks, open Properties of track and set the number of the track.

I am just wondring may be there is a script or plugin for iTunes to re-enumerate tracks.

For example, I have tracks:

Number of Track     Song Name
---------------     ---------
      1               Song A
      2               Song X
      5               Song Y
      8               Song S
     12               Song H

I want to select tracks 5,8 and 12 and enumerate them like this:

Number of Track     Song Name
---------------     ---------
      1               Song A
      2               Song X
      3               Song Y
      4               Song S
      5               Song H

Is there a way to automate this task?

Best Answer

Try this...

tell application "iTunes"
    set iSel to selection

    set n to 1

    repeat with trk in iSel
        set track number of trk to n        
        set n to n + 1
    end repeat
end tell