Last active
May 24, 2025 02:47
-
-
Save ahmedivy/ef8fe029597dacf2cd821dc51c260e08 to your computer and use it in GitHub Desktop.
Script to Categorize DataCamp Slides Automatically
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 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