ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Martin Z on April 03, 2023, 11:07:57 PM

Title: Formatting time values
Post by: Martin Z on April 03, 2023, 11:07:57 PM
Hi Phil / Team,

BACKGROUND
As you'll know (or at least AFAIK) by default time values are formatted depending on their value:

QUERY
I would like to format all times as "HH:MM:SS" and looked into 1-2 ways of doing this, however in my case they don't seem to work and am getting a bit stuck, so wonder if you can help me out please! So far, I've considered...

Are there any other ways of setting/controlling this please?



Appendix:  -d -n conflict
Now, overall I have to say I am big fan of EXIFtool and I do appreciate all the work over the years that has been put into it, so I will let you off for this ;) but that said, I'll confess that I was screaming and cursing your name rather loudly earlier as had spent well over an hour banging my head against a brick wall, trying to figure out why EXIFtool wasn't processing my -d parameter...

EXIFTool.exe -c "%.6f" -d "%d/%m/%Y %H:%M:%S" -n %*
I assumed it was something to do with the parent/wrapping script, or maybe something to do with % being expanded before it reached EXIFtool -- I probably tried 20+ combinations of ", "", %, %%, escaping with ^, delayedexpansion on/off, etc but just could not figure it out!...


... Until I happen to read a footnote in one of the FAQs saying "-n option may be used to disable all of the date/time reformatting"... HUH!? ... OK, well that explains why EXIFtool wasn't processing my -d argument!  >:(  (At least this means my coding isn't quite as bad as I thought! ;D ::) )

[With genuine tone] Please can I suggest adding a note to the -n / -d sections of the manual, explaining that -n will override/negate -d if it is included... While I appreciate it may seem somewhat niche, it did genuinely eat up a big chuck of my time just now (plus, hopefully wouldn't hurt to make this clearer and avoid anyone else running foul of the same combination).
Title: Re: Formatting time values
Post by: StarGeek on April 04, 2023, 01:02:28 AM
From the docs on the -n (--printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv)
    The print conversion may also be disabled on a per-tag basis by suffixing the tag name with a # character

So you can set disable the printconv on individual tags.  For example, with and without the # shortcut
C:\>exiftool -G1 -a -s -Duration -Duration# Y:\!temp\test_drive.MP4
[Kodak]        Duration                        : 0:00:33
[QuickTime]    Duration                        : 0:00:34
[Kodak]        Duration                        : 33
[QuickTime]    Duration                        : 33.7833333333333

So you could use something like
exiftool -if "$Duration#<60" <rest of command>
Title: Re: Formatting time values
Post by: Martin Z on April 10, 2023, 07:53:18 PM
👍🏼 Awesome, thanks @StarGeek!