ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: durianwool on June 02, 2021, 11:03:48 PM

Title: Select -if date range
Post by: durianwool on June 02, 2021, 11:03:48 PM
Hi,
I am not sure what I am doing wrong. As per this post https://exiftool.org/forum/index.php?topic=2129.0 , I should be able to conditionally only process with exiftool using the following:

$ exiftool -if "$CreateDate gt '2020:01:01'" -s -time:all IMG_0050.jpg
    1 files failed condition

where I've checked ...

$ exiftool -s -time:all IMG_0050.jpg
(snipped...)
DateTimeOriginal                : 2021:02:18 08:11:07
CreateDate                      : 2021:02:18 08:11:07
(...)

My usage is to select and process files in a date range, and then output those files to another command. Eg...

exiftool -if "$CreateDate ge '2020:01:01' and $CreateDate lt '2021:01:01'" -p "$FileName" | commandx

Actually I just like to move (or copy) all files with above condition to another directory. Is there already a way to do that in exiftool?

Thanks in advance.


Title: Re: Select -if date range
Post by: StarGeek on June 02, 2021, 11:57:49 PM
You appear to be using a bash type shell.  As per the .sig on any of Phil's posts, you want to swap double/single quotes because otherwise the shell will interpret the $ as the start of a variable. 

To move a file, use the Directory tag (see Writing "FileName" and "Directory" tags (https://exiftool.org/filename.html))

exiftool -if '$CreateDate ge "2020:01:01" and $CreateDate lt "2021:01:01" ' -directory=/path/to/new/directory /path/to/source/files/
Title: Re: Select -if date range
Post by: durianwool on June 03, 2021, 11:33:05 PM
Oh ... I didn't notice that .sig. It works now! Thanks!