Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2023 01:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Screenshot Sorting Mac
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):
# 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