Last active
December 30, 2015 21:49
-
-
Save mo6020/7889813 to your computer and use it in GitHub Desktop.
Quick bash script to find and move any files older than 2 years into an archive 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
# Ed Morgan [ed.morgan@ansgroup.co.uk] | |
# v 0.1 - DIRTY HACKS | |
FROMDIR="/Volumes/HITACHI" | |
TODIR="/Volumes/HITACHI/archive" | |
tmp="~/movelist.$$" | |
cd "$FROMDIR" | |
find . -depth -mtime +730 -printf "%Y %p\n" >$tmp | |
sed 's/^. //' < $tmp | cpio --quiet -pdm "$TODIR" | |
while read -r type name | |
do | |
case $type in | |
f) rm "$name";; | |
d) rmdir "$name";; | |
esac | |
done < $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment