Compare FileModifyDate and DateTimeOriginal within 3 seconds

Started by lei, April 12, 2025, 01:19:17 AM

Previous topic - Next topic

lei

Hi again,

Thanks so much for the earlier help with calculating the time difference between DateTimeOriginal and FileModifyDate. The command using:

-p "$Filename  $DateTimeOriginal $FileModifyDate ${DateTimeOriginal;$_=abs(GetUnixTime($_)-GetUnixTime($self->GetValue('FileModifyDate')))}"

worked great, and it really helped me understand how flexible ExifTool can be. Also, thanks for clarifying the difference between -if and -p expressions — that cleared things up nicely.

While digging into how this works, I had a quick follow-up.

In the ${TAG;EXPR} format, I understand that $_ gives the value of the tag, and we can get other tags using $self->GetValue(...). But I was curious — is there any way to refer to another tag directly inside EXPR, like $FileModifyDate?

I tried it, but it didn't seem to work. The docs mention $_, $tag, and $self, but I couldn't find anything about tag variables being available directly. Just wanted to double-check if that's expected.

Thanks again — still getting my head around all the possibilities with ExifTool, and learning a lot.

Phil Harvey

It is not possible to refer to a tag directly (ie. "${TAG}") from within an advanced formatting expression for 3 reasons.

1. It introduces the possibility of a recursion that makes my brain explode.  eg)

-p "${TAG1;$_=${TAG2;$_={TAG3;$_=${TAG4;$_='enough already!'}}}}"

2. It isn't very common that people want to do this anyway.

3. If you really need to, you already have access other tags via the API functions and the ExifTool $self object in the expression.

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

lei

Hi Phil,

Thank you so much for taking the time to explain all this in such detail. Your reply really helped me understand not only how it works, but also why it works that way. I learned a lot from this discussion.

Thanks again for your help and for developing such an amazing tool!

Best regards