ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: fxstein on October 29, 2022, 04:10:41 PM

Title: if4 date format Issues
Post by: fxstein on October 29, 2022, 04:10:41 PM
Hi,

Have been using -if4 with date logic for a while and it is a very effective tool to make passes of Terabyte-sized libraries.

I generate a UnixEpoch number in zsh that I pass to exiftool like this:

-if4 '${FileModifyDate;DateFmt("%s")} gt 1666957443'

Just recently I needed to default the DateFmt to %s for a series of calculations and I added

-d '%s'

Here is where a strange side effect starts to happen. When combined with the -if4 logic no longer works.

-d '%s' -if4 '${FileModifyDate;DateFmt("%s")} gt 1666957443'

When I remove the -if4 DateFmt it starts working again

-d '%s' -if4 '${FileModifyDate} gt 1666957443'

Shouldn't I be able to define a global date format but be able to override it in some places? It seems that -d '%s' and DateFmt("%s") interfere with each other.

I realize that I can simply drop DateFmt("%s") in this example, but the problem is these are strings from a workflow template that are being assembled into the final exiftool statement.
Title: Re: if4 date format Issues
Post by: StarGeek on October 29, 2022, 04:22:46 PM
The -d (-dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat) is changing the FileModifyDate before the -if option (https://exiftool.org/exiftool_pod.html#if-NUM-EXPR) processes it.  So the DateFmt helper function is receiving the UnixEpoch when it is expecting the regular YY:MM:DD HH:MM:SS format.

You'll want to add a hashtag to the end of FileModifyDate (see the -n (--printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv)) so that the proper value is passed to the DateFmt helper function.

-d '%s' -if4 '${FileModifyDate#;DateFmt("%s")} gt 1666957443'
Title: Re: if4 date format Issues
Post by: fxstein on October 29, 2022, 04:31:33 PM
Thank you very much! That is exactly what I needed.

Title: Re: if4 date format Issues
Post by: Phil Harvey on October 29, 2022, 04:54:27 PM
The bottom line is that it wasn't working because you were applying the %s formatting twice.  Since you added -d %s the DateFmt() was no longer required.

- Phil