For each photo my camera produces both a IMG_NNNN.JPG and a IMG_NNNN.CR2 file, that have exactly the same modification time (which, coming from a FAT-formatted SD card, is always an even number of seconds).
I keep JPG and CR2 separately, but I sometimes need to find the CR2 that corresponds to a given JPG. My current scripts use something like:
find /path/to/CR2s -name $(basename $jpgfile .JPG).CR2
But unfortunately due to numbering rollover using the name alone is no longer sufficient. Using the name and the modification time would be perfect, but something like:
find /path/to/CR2s -name $(basename $jpgfile .JPG).CR2 -newermt "$(stat -c '%y' $jpgfile)"
doesn't work because
newermt seems to perform a strict inequality comparison (same with
newer). In addition
newer... options are not really bullet-proof since searching the CR2 of an old JPG could find the CR2 of a newer homonym.
- Am i overlooking an option in
find(GNU findutils 4.7.0-git)?
- Or is there an elegant way to do this (taking in account that files with the same name are normally years apart)?