2

How do I delete a metadata tag from a FLAC file or MP3 ID3 tag? I can use mutagen to edit information, but how would I delete a single portion of information?

I need to delete a tag entitled fmps_playcount, but not the rest of the metadata.

mh00h
  • 1,824
  • 3
  • 25
  • 45

1 Answers1

2

For ID3 tags you can remove a frame with delall. For example:

>>> print audio.pprint()
TPE1=Agalloch
TALB=The Mantle
TRCK=1/9
TIT2=A Celebration For The Death Of Man...
TCON=Metal
>>> audio.delall('TCON')
>>> print audio.pprint()
TPE1=Agalloch
TALB=The Mantle
TRCK=1/9
TIT2=A Celebration For The Death Of Man...

For deleting the FLAC metadata (I do not have any FLAC files to test this on), I have a good feeling about:

>>> del audio['tag_to_delete']

Since the help documentation has:

 |  __delitem__(self, key)
 |      Delete a metadata tag key.
 |      
 |      If the file has no tags at all, a KeyError is raised.

You can read more about the delitem magic method here: http://www.rafekettler.com/magicmethods.html

mr2ert
  • 5,146
  • 1
  • 21
  • 32
  • this works for ID3 tags like you outlined- thanks. But I also need to do the same for flac files. – mh00h Jul 09 '13 at 04:32