Last active
September 19, 2016 19:54
-
-
Save gooddadmike/d2a12117af7a7c739e53 to your computer and use it in GitHub Desktop.
bash script for clearing old files from a folder
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
#!/bin/sh | |
# for only the given folder, remove files older than 1 day excluding the .DS_Store and the files whose name starts with '_keep' | |
/usr/bin/find /Users/msearcy/Dropbox/images/Wallpapers ! -name '.DS_Store' ! -name 'keep_*' -mtime +1 -maxdepth 1 -type f -exec rm -f {} \; | |
# for the given folder check for a specific md5 hash (image placeholder from ifttt) and delete any file that matches | |
/usr/bin/find /Users/msearcy/Dropbox/images/Wallpapers -type f -exec md5 -r {} + | grep '3993028fcea692328e097de50b26f540' | xargs rm -f | |
# storing this file in ~/Library/Scripts | |
# test echo time ran: $(date '+%Y-%m-%dT%H:%M:%S%z') >> /Users/msearcy/Dropbox/images/Wallpapers/run.log | |
# old script with non-working image search pattern: /find /Users/msearcy/Dropbox/images/Wallpapers -mtime +1 -type f -mindepth 1 -maxdepth 1 -exec file {} \; | awk -F: '{ if ($2 ~/[Ii]mage|EPS/) print $1}' | xargs -0 rm | |
# | |
# cd /Users/msearcy/Dropbox/images/Wallpapers/Portrait & ls -tp | grep -v '/$' | tail -n +26 | tr '\n' '\0' | xargs -0 rm -- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment