Created
March 20, 2015 01:40
-
-
Save tlherr/d57f7b7aa52353f64941 to your computer and use it in GitHub Desktop.
Book Rename
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
import os | |
import re | |
import glob | |
from mobi import Mobi | |
for fn in glob.glob('/Users/Tom/Desktop/Ebooks/*'): | |
print "Renaming {}".format(fn) | |
if os.path.isfile(fn): | |
book = Mobi(fn); | |
book.parse(); | |
s = re.sub('[^0-9a-zA-Z\s]+', '', book.title()) | |
title = "{}-{}.mobi".format(book.author(), s) | |
print title | |
os.rename(fn, title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment