Python code to remove meta data from .mp3 files



How to remove meta data (ID tags) from .mp3 file with Python?


Meta data refers ID3 tags or extra information encoded into mp3 files such as title, artist s name, composer s details, release year, credits, rating and other information related to the album.


These meta data can be removed without altering the quality of the mp3 file, with this Python code.


Install mutagen via command prompt and run the code.


Directory of this program should be in the folder containing .mp3 files.


Most importantly, back-up your files before running this code.


Designed by,

Dr. M Kanagasabapathy



Python code:

import os

import sys

import codecs

from mutagen.mp3 import MP3



if (len(sys.argv) > 1):

fpath = sys.argv[1]


fpath = os.path.abspath(os.path.dirname(sys.argv[0]))


for fn in os.listdir(fpath):


fname = os.path.join(fpath, fn)

if fname.lower().endswith('.mp3'):


mp3 = MP3(fname)




print ('no ID3 tag')

print (' ')

print ('Completed')



YouTube link