I am creating a crontab that compresses 15 minute clips from my security camera into one file (24 Hours Long) and then having the clips delete.
avimerge -o /media/jmartin/Cams/video/Full_$(date +%F --date "Yesterday") -i /media/jmartin/Cams/video/$(date +%F --date "Yesterday")* # Converts files from the past 24 hours into one .avi
rm /media/jmartin/Cams/video/$(date +%F --date "Yesterday")* # Removes old clips that have already been compressed
My question is What is the danger of using the $date variable. Could something possibly happen where it deletes all files in /video/? What would you recommend as a safer alternative?
Example filenames (Yes, those are spaces in the filename):
2016-04-25 00:00:01.avi
2016-04-25 00:15:02.avi
2016-04-25 00:30:02.avi
2016-04-25 00:45:01.avi
clip-2016-04-25 00:00:01.avi
. That way when deleting.../clip-$(date ...)*
files you don't risk to erase the other files. – Emmanuel Apr 25 '16 at 15:23