News:

If this site goes down it is because of the crappy DreamHost web hosting: They will disable your "unlimited traffic" web server if a single bot hammers the site with a moderate load.  If necessary, an alternate ExifTool forum page is available at https://sourceforge.net/p/exiftool/discussion/

Main Menu

Clean DateTimeOriginal from subseconds

Started by exifnewbee, November 19, 2022, 05:02:20 AM

Previous topic - Next topic

exifnewbee

I've organized my pictures with exiftool in directories. So far so good.

However I now found that while I try to import some of those directories into Apple Photos, the date is not correct. After further investigation I found that some of the pics have a subsecond value in the DateTimeOriginal field e.d. [2016:11:05 14:20:51.827]

I believe that is the reason why Apple ignores the DateTimeOriginal and rather uses FileModifyDate which of course is not desired.

Searching for the last hour I believe the subsecond value is not legal in DateTimeOriginal field but I've not come accross a way to fix it automatically. I did test manually fixing it on a single file by removing the subsecond value. After that I can load it correctly into Apple Photos.

So my question is how could I automate this? I didn't find any hint for automatically cleaning the subsecond value from DateTimeOriginal (or ideally to not get lost, push it into the correct SubSecDateTimeOriginal field and writing a valid DateTimeOriginal at the same time). Any help is much appreciated!

Phil Harvey

Are you sure DateTimeOriginal has sub-seconds?  Run this command with ExifTool to be sure:

exiftool -time:all -a -G -s FILE

If the EXIF DateTimeOriginal really does have subseconds, then we can deal with it, but I doubt this is the case.  Sub-seconds are valid for XMP tags, and there are also ExifTool Composite tags which may show subseconds (I think this is what is happening).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

exifnewbee

Hi Phil and thanks for your reply.
Here is the output:
D:\temp-bild-2>exiftool.exe -time:all -a -G -s "Apple-iPhone 6-816x612-021895-subsec.jpg"
[File]          FileModifyDate                  : 2020:01:04 15:07:24+01:00
[File]          FileAccessDate                  : 2022:11:20 10:26:06+01:00
[File]          FileCreateDate                  : 2022:11:20 10:25:41+01:00
[EXIF]          ModifyDate                      : 2016:11:05 14:20:51.827
[EXIF]          DateTimeOriginal                : 2016:11:05 14:20:51.827
[EXIF]          CreateDate                      : 2016:11:05 14:20:51.827
[EXIF]          SubSecTimeOriginal              : 811
[EXIF]          SubSecTimeDigitized             : 811


wywh

Quote from: exifnewbee on November 20, 2022, 04:27:49 AMEXIF]          ModifyDate                      : 2016:11:05 14:20:51.827
[EXIF]          DateTimeOriginal                : 2016:11:05 14:20:51.827
[EXIF]          CreateDate                      : 2016:11:05 14:20:51.827
[EXIF]          SubSecTimeOriginal              : 811
[EXIF]          SubSecTimeDigitized            : 811

Does this happen with every image? What iOS and macOS? What exact iPhone model? What workflow to get the images from the iPhone -- via USB with Image Capture.app or Photos.app (should export unmodified originals), via iCloud or AirDrop (should export metadata edits done on the iPhone)? Can you post a sample image?

- Matti

exifnewbee

No, I don't think it's Apple or general Problem.

It's a large collection of picture which I needed to clean up. Over time it has been accessed and edited with many different tools etc.

In the affected pic I do see:
Software                        : Microsoft Pix (5.161010.0512)

Pictures are taken with an iPhone
Make                            : Apple
Camera Model Name               : iPhone 6

So I could imagine it happened some long time ago when I used some kind of software to organize or edit picture (or metadata).

For me it's really just about getting the collection cleaned from any such issues in order to be able to import it manually into Photos on Mac and to make sure the Metadata is not having screwed up data (as much as possible).


Phil Harvey

#5
Interesting.  You are correct.  Use the following command to fix this:

exiftool "-subsecdatetimeoriginal<exif:datetimeoriginal" "-subseccreatedate<exif:createdate" "-subsecmodifydate<exif:modifydate" FILE

Where FILE is one or more file and/or directory names.

This command will write the EXIF date/time and corresponding sub-second tags via the Composite SubSec tags.

- Phil

Edit: Fixed typo
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

exifnewbee

Thanks Phil!

one more question on that subject: is there a way to first create a list of all affected files to see how big the problem is over the entire collection? Then it would persumably also be better to feed that list as input into the fix you've suggested.

thanks!

Phil Harvey

#7
You could do this:

exiftool -pathname -if "$exif:datetimeoriginal =~ /\./" -r DIR > file_list.txt

Then use the -@ option to feed this file list back to ExifTool.

- Phil

Edit: There are a number of problems with this command.  See this post for the command that actually works.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

exifnewbee


exifnewbee

#9
Playing a bit more with it I found this:

P:\temp-bild>exiftool -time:all -a -G -s IMG_3879-org.jpg
[File]          FileModifyDate                  : 2022:11:26 15:02:47+01:00
[File]          FileAccessDate                  : 2022:11:26 15:02:48+01:00
[File]          FileCreateDate                  : 2022:11:26 15:00:59+01:00
[EXIF]          ModifyDate                      : 2016:07:29 17:58:26
[EXIF]          DateTimeOriginal                : 2016:07:29 17:58:26
[EXIF]          CreateDate                      : 2016:07:29 17:58:26.106
[EXIF]          SubSecTime                      : 106
[EXIF]          SubSecTimeOriginal              : 106
[EXIF]          GPSTimeStamp                    : 17:58:28
[EXIF]          GPSDateStamp                    : 2016:07:29
[Composite]    SubSecDateTimeOriginal          : 2016:07:29 17:58:26.106
[Composite]    SubSecModifyDate                : 2016:07:29 17:58:26.106
[Composite]    GPSDateTime                    : 2016:07:29 17:58:28Z

P:\temp-bild>exiftool -time:all -a -G -s IMG_3879-org.jpg_original
[File]          FileModifyDate                  : 2016:07:29 17:58:26+02:00
[File]          FileAccessDate                  : 2022:11:26 15:01:10+01:00
[File]          FileCreateDate                  : 2022:11:26 15:00:59+01:00
[EXIF]          ModifyDate                      : 2016:07:29 17:58:26.106
[EXIF]          DateTimeOriginal                : 2016:07:29 17:58:26.106
[EXIF]          CreateDate                      : 2016:07:29 17:58:26.106
[EXIF]          GPSTimeStamp                    : 17:58:28
[EXIF]          GPSDateStamp                    : 2016:07:29
[Composite]    GPSDateTime                    : 2016:07:29 17:58:28Z

why does this line not also get changed?
[EXIF]          CreateDate                      : 2016:07:29 17:58:26.106
I had used:
exiftool "-subsecdatetimeoriginal<exif:datetimeoriginal" "-subsecreatedate<exif:createdate" "-subsecmodifydate<exif:modifydate" FILE
thanks!

StarGeek

#10
Quote from: exifnewbee on November 26, 2022, 09:06:48 AMI had used:
exiftool "-subsecdatetimeoriginal<exif:datetimeoriginal" "-subsecreatedate<exif:createdate" "-subsecmodifydate<exif:modifydate" FILE

This command should have returned an error
Warning: Tag 'subsecreatedate' is not defined
Nothing to do.

That's because there is a typo in the original command
"-SubSecCreateDate<exif:createdate"
* 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).

Phil Harvey

Oops.  Thanks.  I fixed this in my post.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

exifnewbee

sorry, but it seems in post 5 you are still missing the second c in "subseccreatedate"

 ???

Phil Harvey

You're right. :/  Not sure where it went because I thought I had added it back again.  Hopefully fixed now.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

exifnewbee

#14
ok now that I've got this out of the way and know how to handle this manually I was trying to automate things. Can't be that difficult? WRONG - I really feel stupid...

You hinted to use -@ to feed the file list back to ExifTool and only now I start to realize I don't get it. Reading about the -@ command I seem to understand I would need to break up the command line statement into individual lines - ok, but I don't see how I could feed the generated list back, in order to process each file?

So here is what I can do manually:

1. Create a list of files which have the subsecond value in their fields:
exiftool -pathname -if "$exif:datetimeoriginal =~ /\./" -r DIR > file_list.txt

file_list.txt look like this:
======== /volume1/Bilder/Working-Pics/sorted/2016/08/iPhone 6/IMG_3937.jpg
======== /volume1/Bilder/Working-Pics/sorted/2016/08/iPhone 6/IMG_4081.jpg
======== /volume1/Bilder/Working-Pics/sorted/2016/08/iPhone 6/IMG_3936.jpg
======== /volume1/Bilder/Working-Pics/sorted/2016/08/iPhone 6/IMG_4082.jpg
======== /volume1/Bilder/Working-Pics/sorted/2016/11/iPhone 6/IMG_4514.jpg
======== /volume1/Bilder/Working-Pics/sorted/2016/11/iPhone 6/IMG_4515.jpg
...

2. and for a 2nd step I want to modify all found files with this:
exiftool "-subsecdatetimeoriginal<exif:datetimeoriginal" "-subseccreatedate<exif:createdate" "-subsecmodifydate<exif:modifydate" -overwrite_original -P FILE

But how do I use "-@" or other options to automate this with my list of 100+ files that were found?





Phil Harvey

Sorry.  There were some crucial errors in my command when writing the file names.  It should have been:

exiftool -filepath -q -s3 -if "$exif:datetimeoriginal =~ /\./" -r DIR > file_list.txt

Then only the file path names are written.  The -s3 option avoids writing the tag names, and the -q option avoids the processing messages.  Also, the proper tag name was FilePath, not PathName.

To "feed this back in" with the -@ option, do this:

exiftool -@ file_list.txt "-subsecdatetimeoriginal<exif:datetimeoriginal" "-subseccreatedate<exif:createdate" "-subsecmodifydate<exif:modifydate" -overwrite_original -P

- Phil

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

exifnewbee

thanks so much! this is now working great!