Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

richard.mac

macrumors 603
Original poster
Feb 2, 2007
6,292
5
51.50024, -0.12662
is there a way to batch change the track name in the format "track number - artist/s - song name" and fill out their respective correct fields with an AppleScript or Workflow or anything? i tried searching Doug's AppleScripts but cant find anything that would help me.

e.g. 01 - Dizzee Rascal Feat. Calvin Harris And Chrome - Dance Wiv Me

Name: Dance Wiv Me
Artist: Dizzee Rascal Feat. Calvin Harris And Chrome
Track Number: 1
 
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
 
script now broken after iTunes 8.1.1 update

Folks,

It appears that after Apple released the recent iTunes update (8.1.1) the script I posted above no longer works. (*sigh* - why does Apple do this?)

If I get it working again, I will post the new version. But I thought I would warn those of you who have the latest iTunes and are having trouble with this script.

-James
 
What is the difference in changing song info this way and going into iTunes and highlighting the tracks that you want to change and right clicking, get info? Then filling adding the info/album art you want. I have been doing it this way for years without any problem. I have moved my music between several different computers and the info always transfers over with the correct info and album art.

I don't know much about script so that is why I am asking.
 
script

JCastro:
The script is useful because you don't want to have to manually change hundreds (or in my case, thousands) of songs by hand. Believe me, after manually changing about 20 songs, you will rapidly succumb to exhaustion.

Anyway, it turns out that the script still works fine if you run it directly from the Script Editor (not from within iTunes 8.1.1).

-James
 
Thread is old, but might be helpful for someone.
Regarding only file renaming based on the metadata information... i.e. "Name.m4a" to "01 - Name.m4a":


Terminal

for f in *.m4a; do for g in `mdls -name kMDItemAudioTrackNumber -raw "$f"`; mv "$f" "$g - $f" ; done;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.