Created
January 18, 2014 13:57
-
-
Save ma6174/8490913 to your computer and use it in GitHub Desktop.
rename music using titie and artist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf-8 | |
import os | |
from mutagen.mp3 import MP3 | |
from mutagen.easyid3 import EasyID3 | |
dir = "/home/ma6174/Music/" | |
for i in os.listdir(dir): | |
real_path = dir + i | |
id3info = MP3(real_path, ID3=EasyID3) | |
new_name = id3info['title'][0] + '-' + id3info['artist'][0] + os.path.splitext(real_path)[1] | |
new_path = dir + new_name.replace('/','').replace(' ','') | |
print "rename", real_path, "==>", new_path | |
os.rename(real_path,new_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment