Skip to content

Instantly share code, notes, and snippets.

@patent-ed
Last active May 6, 2023 16:12
Show Gist options
  • Save patent-ed/70af956fc1f064fdcfc4f628f8c93b6b to your computer and use it in GitHub Desktop.
Save patent-ed/70af956fc1f064fdcfc4f628f8c93b6b to your computer and use it in GitHub Desktop.
a macOS script that removes .ts files older than 7 days from the "Plex Media" folder on the user Teddy's desktop and the /Users/Teddy/Movies folder, you can use a bash script.
#!/bin/bash
# Set directories
plex_media_folder="/Users/Teddy/Desktop/Plex Media"
movies_folder="/Users/Teddy/Movies"
# Find and remove .ts files older than 7 days
find "${plex_media_folder}" -type f -name "*.ts" -mtime +7 -exec rm {} \;
find "${movies_folder}" -type f -name "*.ts" -mtime +7 -exec rm {} \;
echo "Old Plex media files removed successfully."
# This empty's the trash can
osascript -e 'tell application "Finder" to empty the trash'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment