Skip to content

Instantly share code, notes, and snippets.

@crftwr
Created March 5, 2019 01:34
Show Gist options
  • Select an option

  • Save crftwr/9376e27689c533d3882aa470f80bf7f2 to your computer and use it in GitHub Desktop.

Select an option

Save crftwr/9376e27689c533d3882aa470f80bf7f2 to your computer and use it in GitHub Desktop.
Bulk update MP3 ID3 tags
import os
from mutagen.easyid3 import EasyID3
filenames = os.listdir()
filenames = list(filter( lambda name: name.endswith(".mp3"), filenames ))
print( len(filenames) )
filenames.sort()
for i, filename in enumerate(filenames):
id3 = EasyID3(filename)
name, _ = os.path.splitext(filename)
name = name.replace("/","/")
id3["title"] = name
id3["album"] = "Abc"
id3["tracknumber"] = "%d/%d" % ( i+1, len(filenames) )
print(id3)
id3.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment