Skip to content

Instantly share code, notes, and snippets.

@viniciusban
Created March 31, 2013 11:50
Show Gist options
  • Save viniciusban/5280375 to your computer and use it in GitHub Desktop.
Save viniciusban/5280375 to your computer and use it in GitHub Desktop.
How to easily adjust tags of your MP3 files
import glob
# Uses Mutagen package (http://code.google.com/p/mutagen)
# Followed this simple tutorial: http://code.google.com/p/mutagen/wiki/Tutorial
from mutagen.easyid3 import EasyID3
# en: adjust title and tracknumber based on filenames like
# this: "001 My Beautiful Music.mp3"
# pt: ajusta titulo e numero da musica a partir do nome
# do arquivo assim: "001 Minha Música Preferida.mp3"
def adjust_id3(fname):
audio = EasyID3(fname)
audio['title'] = fname[4:].decode('utf-8').split('.')[0]
audio['tracknumber'] = fname[:3]
audio.save()
# en: browse through MP3 files in dir
# pt: percorre lista de arquivos MP3 do diretório
for fname in glob.glob('*.mp3'):
adjust_id3(fname)
# the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment