Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing Single Tag from Audio Files (.MP3 and .FLAC) (Python, Mutagen)

So I'm using Python 3 and Mutagen, and I know how to remove ALL tag metadata from audio files.

For mp3 files, I simply have to use:

from mutagen.easyid3 import EasyID3
audio = EasyID3(filepath)
audio.delete()
audio.save()

For .flac I have to use:

from mutagen.flac import FLAC
audio = FLAC(filepath)
audio.delete()
audio.clear_pictures()
audio.save()

But what if I want to remove just a single tag? For example, what if I only want to clear ONLY the "date" tag? I'm not sure how to do this for either MP3 files or FLAC audio files, and I'd like to know how to do it for both. How would you clear only a single tag with Mutagen in Python? Thanks.

like image 211
EllipticalInitial Avatar asked Oct 23 '25 20:10

EllipticalInitial


1 Answers

You can set the tag as a blank string and save the file but it'll continue to show up when printing the contents as a blank/empty entry

I found that popping the unwanted tag like an entry in a list seems to work. I only tested with FLAC but I'm sure MP3 would be similar

from mutagen.flac import FLAC
audio = FLAC(filepath)
audio.pop('date')
audio.save()
like image 156
imblue Avatar answered Oct 25 '25 11:10

imblue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!