first post. Background- My wife is a photographer, she take a lot of pictures and saves them to a drive (mnt/STStorage) while she is editing them, but never cleans up afterward. I have a drive that i would like to move the folders to based on modified date.(/mnt/LTStorage). Need help with a script that i can add to a cron job to run once a day 30 1 * * * I would like for the script to..
- Check /mnt/STStorage/ root folders for last modified date & if older than 14 days, move that folder and everything in it to /mnt/LTStorage/ while keeping the same folder name.
- Then write what was moved to /mnt/STStorage/ so that we know what was moved and email me a log of folders moved.
OS CentOS 6.4
here is what i have, think this may work for now. Could be cleaner.
#/bin/bash
dt=$(date +%Y.%m.%d)
From="/mnt/STStorage/"
To="/mnt/LTStorage/"
if [[ ! -d "$To" ]]; then
mkdir -p "$To"
fi
cd "$From"
for i in "$@"; do
find . -type d -mtime +14 -exec mv "{}" "$To" \; > "$From"/Moved."$dt".txt
uuencode "$From"/Moved."$dt".txt "$From"/Moved."$dt".txt | mail -s "Files Moved"
me@me.com
done
Then i will add this to crontab to run once a day.