Last active
December 21, 2015 19:09
-
-
Save oeai/6352491 to your computer and use it in GitHub Desktop.
motion bash script for cron.weekly - moves files into separated by month and week folders
This file contains hidden or 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 | |
| #cron weekly | |
| DateMonth=$(date +'%b') #Monthly variable | |
| MotionPath="/var/motion/" | |
| DateWeek=$(date +'%W') | |
| DateWeek=$((DateWeek - 1)) | |
| Mfolder=$MotionPath$DateMonth | |
| Wfolder=$Mfolder/$DateWeek | |
| DataStamp=$(eval date +%j) | |
| create_dir_month() | |
| { | |
| if [ -d $Mfolder ]; then | |
| echo "Got $Mfolder directory"; | |
| else | |
| echo "Creating $Mfolder dir " | |
| mkdir $Mfolder | |
| fi | |
| } | |
| create_dir_week() | |
| { | |
| if [ -d $Wfolder ]; then | |
| echo "Got $Wfolder directory"; | |
| else | |
| echo "Creating $Wfolder dir " | |
| mkdir $Wfolder | |
| fi | |
| } | |
| copy_aj_files() | |
| { | |
| mv $MotionPath/*.avi -t $Wfolder | |
| mv $MotionPath/*.jpg -t $Wfolder | |
| cp $MotionPath/*.php -t $Wfolder | |
| echo "day $DataStamp moved Motion files into subdir $Wfolder" | |
| } | |
| create_dir_month | |
| create_dir_week | |
| copy_aj_files | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment