Created
February 10, 2024 09:37
-
-
Save Eveeifyeve/03158ea58a0369684c2c2266504f96a9 to your computer and use it in GitHub Desktop.
deleteShotsPyScrpt
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 | |
# Set the target directory | |
target_directory = os.path.expanduser('~/documents/screenshots') | |
# Loop through all files in the target directory | |
for filename in os.listdir(target_directory): | |
# Check if the file ends with the extensions we want to delete | |
if filename.endswith('.png') or filename.endswith('.jpg') or filename.endswith('.jpeg'): | |
# Construct full file path | |
file_path = os.path.join(target_directory, filename) | |
# Remove the file | |
try: | |
os.remove(file_path) | |
print(f"Removed {filename}") | |
except OSError as e: | |
print(f"Error: {e.strerror}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment