Welcome, guest | Sign In | My Account | Store | Cart

Remove ID3 tags from all files in the current directory

Python, 27 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
import os
import sys
import codecs
from mutagen.mp3 import MP3

TEXT_ENCODING = 'utf8'

# get workdir from first arg or use current dir 
if (len(sys.argv) > 1):
    fpath = sys.argv[1]
else:
    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'):
        print fn,
        mp3 = MP3(fname)        
        try:
            mp3.delete()
            mp3.save()
            print 'ok!'
        except:
            print 'no ID3 tag'
print 'Done'