Created
August 14, 2021 18:48
-
-
Save Fitzy1293/e3fd8bd7776e9f42433b2ebb2c5b13b5 to your computer and use it in GitHub Desktop.
Calibre script
This file contains hidden or 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 subprocess | |
import os | |
import argparse | |
parser = argparse.ArgumentParser(description='Process some integers.') | |
parser.add_argument('-c,', '--convert', dest='CONVERT_TYPE', help='filetype to convert to') | |
ARGS = parser.parse_args() | |
def convert_to_other_ebook_format(input_ebook, output_format): | |
# book.epub to book.pdf for example | |
output_ebook = input_ebook.split('.epub')[0] + '.' + output_format.replace('.', '') | |
process = subprocess.Popen(['ebook-convert', input_ebook, output_ebook]) | |
process.wait() | |
if __name__ == '__main__': | |
epub_books = [epub for epub in os.listdir(os.getcwd()) if epub.endswith('.epub')] | |
for book in epub_books: | |
convert_to_other_ebook_format(book, ARGS.CONVERT_TYPE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment