Skip to content

Instantly share code, notes, and snippets.

@necrogami
Created January 10, 2013 03:14
Show Gist options
  • Save necrogami/4499130 to your computer and use it in GitHub Desktop.
Save necrogami/4499130 to your computer and use it in GitHub Desktop.
This will create 7z files that are based on the last modified date of the file and it will create an archive for each date and add files to them.
#!/bin/bash
ARCHIVE_FOLDER=/path/to/archive/location
for i in `find -type f -mtime +14`
do
mod=$(date -d"$(stat --printf='%y\n' $i)" +%Y%m%d)
7za a $ARCHIVE_FOLDER/$mod.7z $i
echo "Processed: " $i
rm $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment