Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am trying to create a script that performs various conversions between formats of audio files. In one particular step, I use afconvert in Terminal to convert an mp3 to aac(mpeg4/m4a), but in this process all of the info attached to the audio file (name, artist etc) is lost. I tried to id3cp to copy over the info but this doesn't work (I think because aac files don't use ID3 tags...).

Could someone suggest a way of copying all of the associated info on the mp3 files to the aac (m4a) file? Is there a way it can be retained during the conversion (preferable) or alternately a Terminal command to copy the info over?

share|improve this question
add comment

1 Answer

I prefer the mutagen Python library for tag editing, since it has good support for a wide variety of formats with a consistent interface. Here’s a script for copying the metadata of a file:

import mutagen
import mutagen.easyid3
old = mutagen.easyid3.EasyID3('example.mp3') 
new = mutagen.File('example.m4a') 
new.update(old)
new.save()

You can open any file with mutagen.File, but that gives you raw access to the coded ID3 tags like 'TPE1', instead of human-readable tags like 'artist', so EasyID3 is used instead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.