I wrote an AppleScript (download) for iTunes to set ID3 (metadata) track numbers from number prefixes (ignoring leading zeros) in the filenames. So for filenames like
4 Balloon.mp3 and
5Frou.mp3, the track numbers will be set to
For some reason, many MP3 songs I come across will be well-tagged except for the track number, though present in the filename.
Put the script in
~/Library/iTunes/Scripts, creating the directory if it doesn't exist. A script menu (looking like a stylized scroll) should appear in iTunes. Select a couple of songs and choose the script from the menu to apply it.
I started out with Filenames to Song Names by Doug Adams. Instead of sticking the filename into the song name field, I pipe it through a Ruby one-liner and stick the result into the track number field.