Find files downloaded yesterday

kevinhorsey

Cadet
Joined
Feb 1, 2019
Messages
6
HI

I'm writing a cron job to convert all yesterday's images downloaded to FreeNAS from my IP camera into a movie for easy viewing on my iPhone.

Convert (part of ImageMagick) will convert the jpegs to a movie, but I'm struggling with finding all the images that were downloaded yesterday.

Normally, I'd use the -daystart primary in find, but that isn't available in FreeBSD.

My current solution is to parse the output of date -v-1d with awk to return the month and day of the previous day, use awk to parse find -ls to return a list of all filenames with their month and day of creation/modification, then use grep to return only those files created yesterday, and pass this to the input of convert. Not very elegant!

The problem is that the *time primaries in find only work on a 24 hour period starting/ending now, not yesterday, so I can't use -mtime etc.

I could, of course, always run the cron job at 1 sec past midnight so that the find *time primaries can be used, but I'd rather have the flexibility of running the job at any time the following day.

Can anyone suggest a better solution?

Thanks

Kevin
 

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
You could use -mtime with the find command to find files modified within the last day.

find /path/to/dir -mtime -1d
 
Top