ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: lombardata on February 08, 2023, 12:51:25 AM

Title: Delete images older / newer than specific dates
Post by: lombardata on February 08, 2023, 12:51:25 AM
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 !
Title: Re: Delete images older / newer than specific dates
Post by: Phil Harvey on February 08, 2023, 06:52:53 AM
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
Title: Re: Delete images older / newer than specific dates
Post by: lombardata on February 20, 2023, 06:42:57 AM
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!
Title: Re: Delete images older / newer than specific dates
Post by: Phil Harvey on February 20, 2023, 07:58:28 AM
Sorry.  My mistake.  I've fixed the command in my post.

- Phil
Title: Re: Delete images older / newer than specific dates
Post by: lombardata on February 21, 2023, 12:17:34 AM
Thank you very much, now it works perfectly :D