Can Mathematica edit mp3 tags?

I have a set of files and I'd like to batch process artist, album title, etc. I know other tools exist; I wonder if Mathematica can do it.


Yes. The documentation mentions here that it can import ID3v1, ID3v2 and APE tags. The metadata is returned in a nested association. Now to try it on whatever mp3's I have lying around:

mymp3 = Import["Mick Maguire.mp3", "MetaInformation"]
(* result: {"ID3v2", "ID3v1"} *)

This file happens to have both v1 and v2 tags. Let's check some properties in the ID3v2 tags:

mymp3["ID3v2"][#] & /@ {"Title", "Album"}
(* result: {"Mick Maguire", "The Irish Rovers 50 Years - Vol. 1"} *)

You will want to check that KeyExistsQ for the ID3v2 association exists, try to fall back to ID3v1 if it doesn't, or failing that just skip over it - it's your call how to handle robustness and that the relevant attributes (Title / Album etc.) are present.

Exporting metadata is also straightforward. See here http://wolfram.com/xid/0ck8ulfp-0rbd29 . You must import the audio first however, and here the audio object is in myaudio:

Export["myaudio.mp3", myaudio, 
 MetaInformation -> <|"ID3v2" -> <|"Title" -> "Some Song", 
     "Album" -> "My Album"|>|>]

(* re-import it to check the new metadata is present *)
Import["myaudio.mp3", "MetaInformation"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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