Skip to content

Instantly share code, notes, and snippets.

@mo6020
Last active December 30, 2015 21:49
Show Gist options
  • Save mo6020/7889813 to your computer and use it in GitHub Desktop.
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...
# 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