Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import eyed3, os
- def main():
- print "Track Renamer"
- directory = "songs/" # Assuming "songs" in current directory
- for fnum, file in enumerate(os.listdir(directory)):
- print "\t[%d] - Changing: %s" % (fnum, file)
- if (os.path.isfile(directory+file)) and (file.endswith(".mp3")):
- song = eyed3.load(directory+file)
- try:
- data = os.path.splitext(file)[0].split(" - ")
- song.tag.artist = unicode(data[0])
- song.tag.title = unicode(data[1])
- song.tag.save()
- print "\t[{0}] - Verifying... Artist: '{1}', Track: '{2}'.".format(fnum,song.tag.artist,song.tag.title)
- except:
- print "\t[{0}] - {1} is Nonetype. Skipping...".format(fnum, os.path.splitext(file)[0])
- if __name__ == '__main__':
- main()
- os.system("pause")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement