ARC20190311150800.mp4
Posted: Sat Mar 16, 2019 12:43 pm
I have set up a NAS to which I send files (both .mp4 and .jpg) from my security cameras.
Currently I move the ;.jpg' files from the main directory to another directory called 'jpgFiles', if the files are older than 7 days, but the search for these files is taking longer and longer each day it runs as more files of both type keep loading into the main directory (called 'CCTV') from the security cameras.
the code I currently use to move older files via crontab is
Each file is named in the format as the subject of this thread (starting with ARC, then 4 digits for year, 2 digits for month, 2 digits for day of month, and the rest is the time) with the exception of ending in either .mp4 or .jpg,
I want to archive the lot but to achieve this my problem is :-
1. How do I read out the files individualy first to last and enable me to check the filenames as below.?
2. Once I do this I want to check (split?) the filenames to see if the month and year part of the filename is earlier than this month/year.
3. I will then want to check if I have a subdirectory named monthyear ready to recieve it, If the subdirectory does not exist I want to create it.
4. If the file is earlier I then want to move it to the subdirectory that I have created within this directory.
I will repeat the process for both .mp4 and .jpg files
The reason I want the files moved into their respective months is for archiving and making security checks easier/quicker.
Any pointers would be great
Thanks
WD
Currently I move the ;.jpg' files from the main directory to another directory called 'jpgFiles', if the files are older than 7 days, but the search for these files is taking longer and longer each day it runs as more files of both type keep loading into the main directory (called 'CCTV') from the security cameras.
the code I currently use to move older files via crontab is
Code: Select all
5 8 * * * find /CCTV/RearOfHouse/ -type f -mtime +2 -name '*.jpg' -execdir mv '{}' /CCTV/RearOfHouse/jpgFiles/ \;
I want to archive the lot but to achieve this my problem is :-
1. How do I read out the files individualy first to last and enable me to check the filenames as below.?
2. Once I do this I want to check (split?) the filenames to see if the month and year part of the filename is earlier than this month/year.
3. I will then want to check if I have a subdirectory named monthyear ready to recieve it, If the subdirectory does not exist I want to create it.
4. If the file is earlier I then want to move it to the subdirectory that I have created within this directory.
I will repeat the process for both .mp4 and .jpg files
The reason I want the files moved into their respective months is for archiving and making security checks easier/quicker.
Any pointers would be great
Thanks
WD