Screenshot Sorting Mac
This file contains 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 shutil | |
# Path to the desktop folder | |
desktop_path = os.path.expanduser('~/Desktop') | |
# Path to the screenshots folder on the desktop | |
screenshots_path = os.path.join(desktop_path, 'screenshots') | |
# Create the screenshots folder if it doesn't exist | |
if not os.path.exists(screenshots_path): | |
os.mkdir(screenshots_path) | |
# Get a list of all files on the desktop | |
files = os.listdir(desktop_path) | |
# Loop through each file on the desktop | |
for file in files: | |
# Check if the file is a screenshot | |
if file.startswith('Screen Shot') or file.startswith('Screenshot'): | |
# Construct the path to the file | |
file_path = os.path.join(desktop_path, file) | |
# Construct the path to the new location in the screenshots folder | |
new_file_path = os.path.join(screenshots_path, file) | |
# Move the file to the screenshots folder | |
shutil.move(file_path, new_file_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment