ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: grole on May 02, 2017, 03:31:07 PM

Title: Harmonizing Sub Seconds
Post by: grole on May 02, 2017, 03:31:07 PM
For whatever reason, some of my photos have acquired a single digit in the sub second fields, whereas they should be two digits. This is only where the value is 0. Example of "bad" file:

C:\Users\Administrator>exiftool -a -G0 -time:all E:\Temp\Shift\40D_06579.JPG
[File]          File Modification Date/Time     : 2017:05:02 11:32:38+02:00
[File]          File Access Date/Time           : 2017:05:02 21:01:58+02:00
[File]          File Creation Date/Time         : 2017:05:02 21:01:58+02:00
[EXIF]          Modify Date                     : 2011:02:02 13:04:05
[EXIF]          Date/Time Original              : 2011:01:02 10:37:26
[EXIF]          Create Date                     : 2011:01:02 10:37:26
[EXIF]          Sub Sec Time                    : 0
[EXIF]          Sub Sec Time Original           : 0
[EXIF]          Sub Sec Time Digitized          : 0
[XMP]           Date/Time Original              : 2011:01:02 19:37:26.0+1:00
[XMP]           Create Date                     : 2011:01:02 10:37:26+01:00
[XMP]           Metadata Date                   : 2011:02:02 22:04:05+01:00
[XMP]           Modify Date                     : 2011:02:02 22:04:05.0+1:00
[XMP]           History When                    : 2011:02:02 22:04:05+01:00
[Composite]     Create Date                     : 2011:01:02 10:37:26.0
[Composite]     Date/Time Original              : 2011:01:02 10:37:26.0
[Composite]     Modify Date                     : 2011:02:02 13:04:05.0


... gives the file name: 2011-01-02_10-37-26-0_40D.JPG

Example of "good" file:

C:\Users\Administrator>exiftool -a -G0 -time:all E:\Temp\Shift\40D_06580.JPG
[File]          File Modification Date/Time     : 2017:05:02 11:32:38+02:00
[File]          File Access Date/Time           : 2017:05:02 21:01:58+02:00
[File]          File Creation Date/Time         : 2017:05:02 21:01:58+02:00
[EXIF]          Modify Date                     : 2011:02:02 13:04:09
[EXIF]          Date/Time Original              : 2011:01:02 10:37:31
[EXIF]          Create Date                     : 2011:01:02 10:37:31
[EXIF]          Sub Sec Time                    : 00
[EXIF]          Sub Sec Time Original           : 00
[EXIF]          Sub Sec Time Digitized          : 00
[XMP]           Date/Time Original              : 2011:01:02 10:37:31+01:00
[XMP]           Create Date                     : 2011:01:02 10:37:31+01:00
[XMP]           Metadata Date                   : 2011:02:02 22:04:09+01:00
[XMP]           Modify Date                     : 2011:02:02 13:04:09+01:00
[XMP]           History When                    : 2011:02:02 22:04:09+01:00
[Composite]     Create Date                     : 2011:01:02 10:37:31.00
[Composite]     Date/Time Original              : 2011:01:02 10:37:31.00
[Composite]     Modify Date                     : 2011:02:02 13:04:09.00


... gives the file name: 2011-01-02_10-37-31-00_40D.JPG

This wouldn't matter normally, but I'm re-naming a large set of images based on time/date including sub seconds which is supposed to correspond to the edited set of the same images. This might give different file names for the same image. i.e. one with 0 and the corresponding one with 00

So my thinking is to just check if the value is "0" and in that case, overwrite it with "00".

I've been trying out variations of the following but I can't get it to work. Any ideas?

exiftool -if "$subsectimedigitized=0" "subsectimedigitized=00" e:\temp\shift -overwrite_original

Thanks in advance.
Title: Re: Harmonizing Sub Seconds
Post by: StarGeek on May 02, 2017, 03:53:26 PM

In your example, you're forgetting the dash
"-subsectimedigitized=00"

Also, you might try
-if "$subsectimedigitized eq '0'"

If you use an equal sign, that will compare the value numerically, and 00 is the same as 0.  Using eq compares them as a string and in that case 0 is not the same as 00, so only files that are actually just 0 will be processed.

Example output:
C:\>exiftool -g1 -a -s -SubSecTime X:/!temp/!MetadataTestImages/2011-12-17_11.23.23.Jpg
---- ExifIFD ----
SubSecTime                      : 0

C:\>exiftool -P -overwrite_original -if "$SubSecTime eq '0'" -SubSecTime=00 X:/!temp/!MetadataTestImages/2011-12-17_11.23.23.Jpg
    1 image files updated

C:\>exiftool -g1 -a -s -SubSecTime X:/!temp/!MetadataTestImages/2011-12-17_11.23.23.Jpg
---- ExifIFD ----
SubSecTime                      : 00
Title: Re: Harmonizing Sub Seconds
Post by: grole on May 02, 2017, 04:07:28 PM
Great, that's what I was missing!

I was aware of the numerical/string thing but didn't know about the "eq" bit.

I corrected all three at once, just to be sure:

exiftool -if "$subsectimedigitized eq '0'" -subsectimedigitized=00 -subsectime=00 -subsectimeoriginal=00 e:\temp\shift -overwrite_original

Thanks a lot!