Skip to content

Instantly share code, notes, and snippets.



Created Jan 1, 2020
What would you like to do?
Shell script to delete old files and empty directories
# This will delete JPG files more than 7 days old
# and video files more than 21 days old
# it will also delete old empty directories
find $CPATH/images -name "*.jpg" -type f -mtime +7 -delete
find $CPATH/images -name "*.mp4" -type f -mtime +21 -delete
find $CPATH/images -type d -exec rmdir {} + 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.