if4 date format Issues

Started by fxstein, October 29, 2022, 04:10:41 PM

Previous topic - Next topic

fxstein

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.
If you want to help fix GoPro and related EXIF metadata please check out: https://github.com/fxstein/GoProX

StarGeek

The -d (-dateFormat) option is changing the FileModifyDate before the -if option 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) so that the proper value is passed to the DateFmt helper function.

-d '%s' -if4 '${FileModifyDate#;DateFmt("%s")} gt 1666957443'
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

fxstein

Thank you very much! That is exactly what I needed.

If you want to help fix GoPro and related EXIF metadata please check out: https://github.com/fxstein/GoProX

Phil Harvey

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
...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 ($).