Delete images older / newer than specific dates

Started by lombardata, February 08, 2023, 12:51:25 AM

Previous topic - Next topic

lombardata

Hi everyone,
I would like to know if someone knows how to delete all images in a directory on time condition, e.g. :
exiftool -if (datetimeoriginal le "2023:02:07 06:47:13.100" or datetimeoriginal ge "2023:02:07 06:59:12.600") -delete
Thank you in advance !

Phil Harvey

#1
ExifTool won't delete image files, but you can move them to a directory and delete them yourself.  Assuming you are on Mac or Linux, it would look something like this:

exiftool -if '$datetimeoriginal le "2023:02:07 06:47:13.100" or $datetimeoriginal ge "2023:02:07 06:59:12.600"' -directory=delete DIR

then

rm -rf delete

but you should make sure the desired images are in the "delete" directory before you dispose of them.  It is fairly easy to blunder the -if syntax.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

lombardata

ok, thank you very much Phil.
I tried :
exiftool -if 'datetimeoriginal le "2023:02:07 06:43:48.600" or datetimeoriginal ge "2023:02:07 06:43:50.800"' -directory=delete_dir frames_dir -v3and the output is :
QuoteCondition: Bareword "datetimeoriginal" not allowed while "strict subs" in use - frames_dir/session_2023_02_07_hermitage_plancha_body_v1A_00_2_2167.jpeg
-------- frames_dir/session_2023_02_07_hermitage_plancha_body_v1A_00_2_2167.jpeg (failed condition)
for each image in the directory.
Obviously I checked that there are some images with the datetimeoriginal exif tag in between, but at the end the delete_dir is still empty.
Do you have any idea ?
Have a good day!

Phil Harvey

Sorry.  My mistake.  I've fixed the command in my post.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

lombardata