Based on experimentation and my reading of the instructions, FAQ and various forum posts, it looks to me like it's not possible to shift EXIF:SubSecTimeOriginal. If it IS possible, can somebody please give an example? If not, I'd like to request such a feature if feasible.
In what way are you having problems shifting it? Shifting works here
C:\>exiftool -g1 -a -s -SubSecTimeOriginal y:\!temp\Test4.jpg
---- ExifIFD ----
SubSecTimeOriginal : 75
C:\>exiftool -P -overwrite_original -SubSecTimeOriginal+=5 y:\!temp\Test4.jpg
1 image files updated
C:\>exiftool -g1 -a -s -SubSecTimeOriginal y:\!temp\Test4.jpg
---- ExifIFD ----
SubSecTimeOriginal : 80
Handling the overflow is tricky because DateTimeOriginal needs to be updated. This is the easiest way I can think of doing this:
exiftool "-subsectimeoriginal<${subsecdatetimeoriginal;ShiftTime('0:0:0.2')}" "-datetimeoriginal<${subsecdatetimeoriginal;ShiftTime('0:0:0.2')}" FILE
This increments by 0.2 seconds. Unfortunately you need to change the value in 2 places in the command when you change this.
- Phil
Edit: StarGeek has a better solution below.
Quote from: StarGeek on December 15, 2021, 02:01:44 PM
In what way are you having problems shifting it?
Apparently I'm not after all. Looks like I'd neglected to change a value to something other than 0 in my command line to perform the shifting. My bad.
Quote from: Phil Harvey on December 15, 2021, 02:25:51 PM
Handling the overflow is tricky because DateTimeOriginal needs to be updated. This is the easiest way I can think of doing this:
Thanks, I'll keep that in mind, though I don't expect to run into any overflow problems the way I'm utilizing it. Basically, I'm experimenting with using EXIF:SubSecTimeOriginal and XMP:DateTimeOriginal (with a subsecond component) to represent page order of multi-page document and publication scans when viewed in systems that appear to sort strictly by DateTimeOriginal, like Google Photos (in my experience, anyway). Up until now, I was accomplishing this by shifting whole seconds based on page numbers, but I would prefer to leave seconds/minutes/hours alone if possible.
I do have another question about both EXIF:SubSecTimeOriginal and XMP:DateTimeOriginal, though: I found that I can store and shift four-digit subsecond values in both tags, which is probably sufficient to handle any of my use cases, though I imagine both tags are typically used with three-digit values or less. Is there any particular practical limit to the number of subsecond digits stored and/or shifted in either tag?
The EXIF specification puts no restriction on the number of digits.
- Phil
Ok, thanks.
Based on this:
Quote from: StarGeek on June 12, 2020, 12:04:55 AM
"-DateTimeOriginal+<0:0:${Filename;m/0*(\d+)\./;$_=$1}"
...and this:
Quote from: StarGeek on February 18, 2021, 11:01:20 PM
The .= operator is the same as $_=$_.'0'x(3-length), takes the value of subsectimeoriginal and adds to the end as you found out. What you want is to swap the positions, $_='0'x(3-length).$_
...I'm trying to work out shifting both EXIF and XMP subseconds, initially set to
0000, by page numbers extracted from filenames, where the page numbers might be 1–4 digits, with or without leading zeros. For example:
Filename "2020-10-11 12;13;14 - Document - 01.png"
ExifTool -m "-EXIF:SubSecTimeOriginal+<${Filename;m/0*(\d+)\./;$_='0'x(4-length).$1}" "-XMP:DateTimeOriginal+<0:0:${Filename;m/0*(\d+)\./;$_='0'x(4-length).$1}" .Desired results:
XMP:DateTimeOriginal = 2020:10:11 12:13:15.0001
EXIF:SubSecTimeOriginal = 0001
Actual results:
XMP:DateTimeOriginal = 2020:10:11 12:13:15.0000
EXIF:SubSecTimeOriginal = 1
Not quite sure what I need to do to get them both right, if possible.
.
I should point out that I realize, in the example and conditions I provided, I could simply SET at least EXIF:SubSecTimeOriginal to the necessary zero-padded value, but I do expect to have situations in which shifting will be necessary.
You dropped a very important part of that first example, $_=$1. So in the following commands, length is returning the length of the original filename, which leads to 4-39= negative 35 leading zeros.
Also, for XMP:DateTimeOriginal, you haven't included the seconds, so the resulting variable is added to the seconds, not as subseconds.
In the case of SubSecTimeOriginal, the leading zeroes are being stripped off. Adding 0. will fix that. (This actually threw me for a bit until I figured it out)
Try
exifTool -m "-EXIF:SubSecTimeOriginal+<0.${Filename;m/0*(\d+)\./;$_=$1;$_='0'x(4-length).$_}" "-XMP:DateTimeOriginal+<0:0:0.${Filename;m/0*(\d+)\./;$_=$1;$_='0'x(4-length).$_}" /path/to/files/
Example output:
C:\>exiftool -G -a -s -DateTimeOriginal -SubSecTimeOriginal "Y:\!temp\bbbb\2020-10-11 12;13;14 - Document - 01.png"
[XMP] DateTimeOriginal : 2020:10:11 12:13:15.0000
[EXIF] SubSecTimeOriginal : 0
C:\>ExifTool -m "-EXIF:SubSecTimeOriginal+<0.${Filename;m/0*(\d+)\./;$_=$1;$_='0'x(4-length).$_}" "-XMP:DateTimeOriginal+<0:0:0.${Filename;m/0*(\d+)\./;$_=$1;$_='0'x(4-length).$_}" "Y:\!temp\bbbb\2020-10-11 12;13;14 - Document - 01.png"
1 image files updated
C:\>exiftool -G -a -s -DateTimeOriginal -SubSecTimeOriginal "Y:\!temp\bbbb\2020-10-11 12;13;14 - Document - 01.png"
[XMP] DateTimeOriginal : 2020:10:11 12:13:15.0001
[EXIF] SubSecTimeOriginal : 0001
Quote from: StarGeek on December 21, 2021, 10:03:59 PM
Try
exifTool -m "-EXIF:SubSecTimeOriginal+<0.${Filename;m/0*(\d+)\./;$_=$1;$_='0'x(4-length).$_}" "-XMP:DateTimeOriginal+<0:0:0.${Filename;m/0*(\d+)\./;$_=$1;$_='0'x(4-length).$_}" /path/to/files/
That worked perfectly. Thanks again! And Merry Christmas and Happy New Year to all!
Quote from: Phil Harvey on December 15, 2021, 02:25:51 PM
exiftool "-subsectimeoriginal<${subsecdatetimeoriginal;ShiftTime('0:0:0.2')}" "-datetimeoriginal<${subsecdatetimeoriginal;ShiftTime('0:0:0.2')}" FILE
Since
SubSecDateTimeOriginal is writable, it looks like this works correctly, writing both tags at once.
C:\>exiftool -time:all --system:all -G -a -s y:\!temp\Test4.jpg
[EXIF] DateTimeOriginal : 2020:10:11 12:13:15
[EXIF] SubSecTimeOriginal : 99
[Composite] SubSecDateTimeOriginal : 2020:10:11 12:13:15.99
C:\>exiftool -P -overwrite_original "-SubSecDateTimeOriginal<${SubSecDateTimeOriginal;ShiftTime('0:0:0.02')}" y:\!temp\Test4.jpg
1 image files updated
C:\>exiftool -time:all --system:all -G -a -s y:\!temp\Test4.jpg
[EXIF] DateTimeOriginal : 2020:10:11 12:13:16
[EXIF] SubSecTimeOriginal : 01
[Composite] SubSecDateTimeOriginal : 2020:10:11 12:13:16.01
Quote from: StarGeek on December 26, 2021, 01:04:13 AM
Since SubSecDateTimeOriginal is writable, it looks like this works correctly, writing both tags at once.
Hey, that's cool. Like I wrote earlier in this thread, subseconds rollover isn't something I'm currently having to deal with, but I'll certainly file this trick for possible future reference. I'm sure it will come in handy sooner or later.
Quote from: StarGeek on December 26, 2021, 01:04:13 AM
Since SubSecDateTimeOriginal is writable, it looks like this works correctly, writing both tags at once.
ExifTool (and StarGeek) never cease to amaze me. ;)
- Phil