Skip to content

Instantly share code, notes, and snippets.

@daniel-woods
Created February 5, 2015 11:29
Show Gist options
  • Save daniel-woods/af0876aa6a11e2da36c7 to your computer and use it in GitHub Desktop.
Save daniel-woods/af0876aa6a11e2da36c7 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#Executes from the folder the script is called from.
#Recursively scans dirs for predetermined file extensions
import os
from subprocess import call
from time import strftime
for root, dirnames, filenames in os.walk(os.path.dirname(os.path.realpath(__file__))):
for filename in filenames:
if filename.endswith(('.epub','.pdf','.azw3','.lit')):
src=root+'/'+filename
dst=root+'/'+os.path.splitext(filename)[0]+'.mobi'
if not os.path.isfile(dst):
try:
print(time.strftime("%X"),filenames.index(filename),'/',len(filenames))
w = subprocess.call(['ebook-convert', src,
dst])
except Exception as err:
print(err)
#End of File.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment