I just wrote an AppleScript to set this information. It's not thoroughly tested and does not have extensive error checking, so keep that in mind. Here's what it does:
*It loops through all the tracks of the front playlist. So if you want it to go through your whole library, make sure your library is selected, otherwise I'd suggest created a temporary playlist with the songs you want it to go through.
*It checks to see how many parts the name has (defined as being separated by a hyphen). If there is 1, the script effectively does nothing. If there are 2, it uses the track#-song format (eg "2-TheSong.mp3"). If there are 3 (or more), it uses the track#-artist-song format, and any extra parts are included in the tack name. Eg "3-TheArtist-The-Song.mp3" will come out with track number 3, artist "TheArtist", and name "The-Song".
*If the first part is not an integer, it is ignored, and the track number is not changed.
*No other fields are changed.
To use the script, follow these instructions:
1. Open /Applications/AppleScript/Script Editor.
2. Type in the following code:
Code:
tell application "iTunes"
set theTracks to every track of view of browser window 1
set delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"-"}
repeat with trackNo from 1 to (count of theTracks)
set trackName to name of item trackNo of theTracks
set numWords to count of text items of trackName
try
set currTrack_track to text item 1 of trackName as integer
on error
set currTrack_track to -1
end try
if numWords is greater than 1 then
if numWords is greater than 2 then
set currTrack_song to text items 3 thru numWords of trackName as string
set currTrack_artist to text item 2 of trackName
else
set currTrack_song to text item 2 of trackName
set currTrack_artist to ""
end if
else
set currTrack_song to trackName
set currTrack_artist to ""
end if
if currTrack_track is greater than -1 then
set track number of item trackNo of theTracks to currTrack_track
end if
if currTrack_artist is not equal to "" then
set artist of item trackNo of theTracks to currTrack_artist
end if
set name of item trackNo of theTracks to currTrack_song
end repeat
set AppleScript's text item delimiters to delim
end tell
3. Make sure iTunes is open with the correct playlist selected
4. Click the Run button in Script Editor.
5. If you want to save the script for further use, save as script, and save it in Home/Library/iTunes/Scripts. Then you can use it from the Scripts menu in iTunes.
If you have any problems with the script, or want it to use a different naming format, separator etc, please tell me and I will do my best to help.