Batch Update of Album Name


#1

iTunes shows my album names in the format "(2018) - greatest Hits", in other words the albums year in brackets followed by the album name. this Album name tag is held within the iTunes library, I would like to update the relevant tag within the actual MP3 file name, this is doable from within the MP3TAG application but with over 12,000 albums collected and digitised over many years I would like to put a script together that will do a batch update taking the iTunes Album name and applying it to the MP3 file, I wrote an AppleScript for iTunes on my Apple Mac which updated the album name so I just need to know the terminal/command line script/command. if some one could help please.


#2

There is no such thing as a command line to update fields/tags.
You would have to get iTunes to write all its information to the tags - in the old days this could be achieved with the iTunes function to change the tag type - even from V2.3 to V2.3 - so no change happened but the information still ended up in the files. You have to try if this function is still available.


#3

Thanks ohrenkino for the reply, I am very good with AppleScript and iTunes, so I wrote a script that does exactly that, it applies the relevant details to the Album name and saves the details in the iTunes library but unfortunately it does not actually update the tags within the MP3 files.

If anyone would like a copy of my AppleScript please reply and I will make it available for free. what follows is a copy/paste of the script but happy to zip it etc.

(*

26 Artists Place Album Year Number in front of Album Name where no open bracket exists

*)

tell application "Finder"

set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}

set AppName to ( text item -1 of ( text 1 thru -6 of the ( path to me as string )))

set AppleScript's text item delimiters to TID

display notification "Procedure Started: " & return & AppName with title "Information Messge"

delay 1

end tell

set progress total steps to -1

set progress completed steps to -1

set progress description to "Updating Album Name from Year number & Album Name:"

set progress additional description to "Preparing to process..." & return

tell application "iTunes"

set sel to ( every file track of playlist "Library" whose album does not start with "(")

-- set sel to selection

set selR to a reference to sel

if sel is {} then

display dialog return & "No albums are selected..." buttons {"Cancel"} default button 1 with icon 0 giving up after 15

return

end if

tell me to {progress description, progress additional description}

set Procedurestartdate to current date

set number_of_tracks_to_process to (length of sel)

log "number_of_tracks_to_process = " & number_of_tracks_to_process

set number_of_albums_to_process to 0

set number_of_albums_processed to 0

set list_Of_Album_Names to {}

set new_Album_Name to ""

set the_artist_name to ""

set other_chars to "()"

set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}

repeat with i from 1 to number_of_tracks_to_process

-- get number of albums to be processed

set Current_Track to item i of selR

set current_Album_Name to (Current_Track's album as string )

log "current_Album_Name - " & current_Album_Name

if list_Of_Album_Names does not contain current_Album_Name then

copy current_Album_Name to end of list_Of_Album_Names

set number_of_albums_to_process to number_of_albums_to_process + 1

end if

end repeat

log "Number of albums = " & number_of_albums_to_process

tell me to set progress total steps to number_of_tracks_to_process

set completedsteps to 0

tell me to dispmsg(1, number_of_tracks_to_process, -1, number_of_albums_to_process, number_of_albums_processed, "", "")

repeat with i from 1 to number_of_tracks_to_process

log "track number = " & i & " of " & number_of_tracks_to_process

set thisTrack to item i of selR

set theFileLocation to { get thisTrack's location}

set the_artist_name to { get thisTrack's artist} as string

set the_Album_Name to { get thisTrack's album} as string

-- log "thealbum - " & the_Album_Name

set the_Track_year to { get thisTrack's year}

-- log "thetrackyear - " & the_Track_year

set new_Album_Name to "(" & the_Track_year & ") - " & the_Album_Name

set thisTrack's album to new_Album_Name

set number_of_albums_processed to number_of_albums_processed + 1

set completedsteps to completedsteps + 1

tell me to dispmsg(i, number_of_tracks_to_process, completedsteps, number_of_albums_to_process, number_of_albums_processed, the_artist_name, the_Album_Name)

end repeat

set AppleScript's text item delimiters to TID

set Text_To_Be_Read_Out to "procedure complete" as text

say Text_To_Be_Read_Out

set ProcedureEndDate to current date

if Procedurestartdate > ProcedureEndDate then

set time_Difference_in_seconds to Procedurestartdate - ProcedureEndDate

else

set time_Difference_in_seconds to ProcedureEndDate - Procedurestartdate

end if

set Total_seconds_of_Run_Time to time_Difference_in_seconds

set Total_Hours to (time_Difference_in_seconds div hours)

set Total_minutes to (time_Difference_in_seconds div minutes)

if Total_Hours is equal to 1 or Total_Hours is greater than 1 then

set Total_minutes to Total_minutes - (Total_Hours * 60)

log "Total minutes " & Total_minutes

end if

set Total_Seconds to (time_Difference_in_seconds mod minutes)

set ElapsedTimeDisplay to "Elapsed time: " & Total_Hours & " Hours " & Total_minutes & " Minutes " & Total_Seconds & " Seconds"

display dialog "Procedure Complete. " & return & return & number_of_albums_to_process & " Album Names Updated" & return & return & "Started at: " & Procedurestartdate & return & return & "Compleated at: " & ProcedureEndDate & return & return & ElapsedTimeDisplay buttons {"Thank You"} default button 1 with title AppName with icon 1

end tell

on dispmsg(i, number_of_tracks_to_process, completedsteps, number_of_albums_to_process, number_of_albums_processed, the_artist_name, the_Album_Name)

set progress additional description to return & "Album Details:- " & return & return & "Total Number of Albums to Process: " & number_of_albums_to_process & return & return & "Track Number: " & i & " of " & number_of_tracks_to_process & return & return & "Artist: " & the_artist_name & return & return & "Album: " & the_Album_Name & return & return & "Updating iTunes Library" & return

delay 0.2

set progress completed steps to completedsteps

end dispmsg