Skip to content

Instantly share code, notes, and snippets.

@kazimuth
Created August 12, 2012 22:26
Show Gist options
  • Save kazimuth/3334942 to your computer and use it in GitHub Desktop.
Save kazimuth/3334942 to your computer and use it in GitHub Desktop.
Python script to rename your music files!
#James Gilles, 2012
#DWTFYWWI License
from mutagen.easyid3 import EasyID3
import os
print "input directory for processing: "
path = raw_input()
os.chdir(path)
file_list = filter((lambda x: '.mp3' in x), os.listdir(path))
for i in file_list:
print "file: "+i
try:
current = EasyID3(i)
newname = current["title"][0] + ".mp3"
newname.replace(" ", "_")
del current
print "renaming "+i+" to "+newname
os.rename(i, newname)
except:
print "...that file didn't work for some reason."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment