Skip to content

Instantly share code, notes, and snippets.

@sompodsign
Forked from bergpb/convert_pdf_epub.py
Created May 24, 2023 02:52
Show Gist options
  • Save sompodsign/fdc0b168e3c4d2cfe225da31eba58a67 to your computer and use it in GitHub Desktop.
Save sompodsign/fdc0b168e3c4d2cfe225da31eba58a67 to your computer and use it in GitHub Desktop.
Script to convert pdf to epub.
import os
from time import sleep
path = os.getcwd()
files = os.listdir(path)
#install package
os.system('sudo apt install calibre -y && sudo apt update')
#remove espacos e insere _
for file in files:
os.rename(os.path.join(path, file), os.path.join(path, file.replace(' ', '_')))
for file in files:
if file.endswith('.pdf'):
f = file.split('.')
f = f[0]
os.system('ebook-convert {} {}.epub'.format(file, f))
sleep(10)
print ('Finalizado.....')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment