Skip to content

Instantly share code, notes, and snippets.

@ahmedivy
Created February 22, 2023 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmedivy/ef8fe029597dacf2cd821dc51c260e08 to your computer and use it in GitHub Desktop.
Save ahmedivy/ef8fe029597dacf2cd821dc51c260e08 to your computer and use it in GitHub Desktop.
Script to Store DataCamp Slides Efficiently and Automatically
import os
import re
import fitz
DESTINATION = r"<your_destination_folder_to_save_notes>"
path = os.path.join(os.path.expanduser('~'), 'Downloads')
files = [f for f in os.listdir(path) if re.search(r'chapter.+\.pdf', f)]
for file in files:
doc = fitz.open(os.path.join(path, file))
courseName = doc[1].get_text().splitlines()[0].title()
chapter = file[7]
if not os.path.exists(os.path.join(DESTINATION, courseName)):
os.mkdir(os.path.join(DESTINATION, courseName))
print(f"Created '{courseName}' folder")
if not os.path.exists(os.path.join(DESTINATION, courseName, f"Chapter {chapter}.pdf")):
doc.save(os.path.join(DESTINATION, courseName, f"Chapter {chapter}.pdf"))
print(f"Saved Chapter {chapter} of '{courseName}'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment