Applescript to batch rename tracks
I had the same problem. After hunting around for various scripts, I finally bought a copy of Stern's book on iTunes hacks and found mostly what I was looking for.
Below is my own customized script that does the batch renaming for files whose title tags are in the form "001 - Artist Name - Song Title" and splits the string and populates the appropriate tags for each song.
To use this script, cut and paste text below to a text file and save it to a file "rename.sctpd" in your Library/iTunes/Scripts folder. Then highlight the tracks you want to auto-rename and invoke the script from the script menu.
I hope this helps.
-James
------------
(* batch renaming script for iTunes
James Kuffner
March 3, 2009
Splits iTunes tracks titled as "001 - Artist Name - Song Title" into
the respective track number, artist, and title fields
*)
-- CONSTANTS
property separator : " - "
property my_title : "Split Delimited Title into Track, Artist, Title"
tell application "iTunes"
if selection is not {} then -- if tracks are selected...
set sel to selection
set numTracks to (length of sel)
set s to "s"
if numTracks is 1 then set s to ""
display dialog "parse and split the title name text into artist field and track field." & return & return & (numTracks & " track" & s & " selected.") buttons {"Cancel", "Continue"} default button 2 with title my_title giving up after 30
if gave up of result is true then return
set oldfi to fixed indexing
set fixed indexing to true
repeat with aTrack in selection
tell aTrack
if name contains separator then
set {track number, artist, name} to my text_to_list(name, separator)
end if
end tell
end repeat
set fixed indexing to oldfi
else
display dialog "No tracks have been selected." buttons {"Cancel"} default button 1 with icon 0 giving up after 30
end if -- no selection
end tell
on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
try
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
on error errStr number errNum
set AppleScript's text item delimiters to saveD
error errStr number errNum
end try
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list