Created
August 8, 2018 17:08
-
-
Save awade/ff691f1a74736177e8f4c70d8ba47f25 to your computer and use it in GitHub Desktop.
Minimalist bash script for cleaning downloads folder on a mac. Logs which were files deleted. Configured for deleting files older than 7 days. Call from crontab to automate. Use at own risk.
This file contains hidden or 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
#!/bin/bash | |
# | |
# Cleans a mac computer directory when called from crontab | |
# | |
#Author: Andrew Wade | |
#Date: 20170125 | |
#Last modified: yyyymmdd | |
TIMESTAMP=$(date +"%Y%m%d-%H%M%S") | |
DIR="$HOME/Downloads/" | |
LOGFILE="$HOME/roombaroo.log" | |
echo "Cleanup script run $TIMESTAMP on folder $DIR" >>${LOGFILE} | |
find $DIR* -type f -ctime +7 -print0 | xargs -0 rm -v >> ${LOGFILE} | |
find $DIR. -empty -type d -delete | |
echo "------------------ Script finished -----------------" >>${LOGFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment