Skip to content

Instantly share code, notes, and snippets.

@ndzn
Created July 13, 2023 01:17
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 ndzn/60f13806f9a2db2e07ad2339b37011a3 to your computer and use it in GitHub Desktop.
Save ndzn/60f13806f9a2db2e07ad2339b37011a3 to your computer and use it in GitHub Desktop.
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):
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