ExifTool Forum

ExifTool => Newbies => Topic started by: AMAMSNL on September 04, 2022, 10:28:26 AM

Title: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: AMAMSNL on September 04, 2022, 10:28:26 AM
Windows 11 dutch language setting, exiftool v 12.44

I am a newbie  ::)

I am trying to ad missing/wrong  timestamps to some media files downloaded from takeout (Google).
All files came with 1 unique corresponding Json files containing the missing date info.
I saw that Google will not remove any meta data so problably this information went lost over the years.

Anyway I have .jpg .png .mp4 .Heiv .H264 files all using different labels for what I am after:
importing the date as close as possible to the original creation date.
I realise that there are many interpretations apart from the format, for the date I am after.

I have been experimenting with some commands:

exiftool -r -d %s -tagsfromfile "%d/%F.json" "-GPSAltitude<GeoDataAltitude" "-GPSLatitude<GeoDataLatitude" "-GPSLatitudeRef<GeoDataLatitude" "-GPSLongitude<GeoDataLongitude" "-GPSLongitudeRef<GeoDataLongitude" "-Keywords<Tags" "-Subject<Tags" "-Caption-Abstract<Description" "-ImageDescription<Description" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -ext "*" -overwrite_original -progress --ext json

I ended up with:
10% of files now dated 1-1-1970 and no picture taken date, true for MP4 files only.
However there are 509 files out of 6750 media files, MP4 only that have a correct (creation) date, simular to photo taken date.
There are a few .jpg files that have the correct date.
But the bulk of the files show a Creation Date/Time 2022:08:18 09:17 (which is the take out export date)
While the corresponding Json file shows:

"title": "6c2f78c0-43f8-427a-af4d-06b006dc5a78.jpg",
  "description": "",
  "imageViews": "1",
  "creationTime": {
    "timestamp": "1586884805",
    "formatted": "14 apr. 2020 17:20:05 UTC"
  },
  "photoTakenTime": {
    "timestamp": "1544994008",
    "formatted": "16 dec. 2018 21:00:08 UTC"

I attach an excel (xlsx/ods) file showing the meta data of 5 different media files and the corresponding JSON file content written below meta data, in the same column.

I hope someone can help me trying to construct a command for exiftool that will import, I guess oldest date exiftool can find in the relevant Json file for the media file that matches and inserts this as creation date and/or phototaken / media created date.
If thats not possible for all these different files with there own meta data lay out and lables is there a way I can sort out all the diffent meta data layouts in my unzipped takeout files. so i can construct a command for each unique layout?

Kudoos for the developer, I know what pain we went through getting texts formats ONLY, displaying properly. Adding exif data spaghetti is a whole different dimension. RESPECT !!!
Title: Re: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: StarGeek on September 05, 2022, 01:07:57 PM
Quote from: AMAMSNL on September 04, 2022, 10:28:26 AMI ended up with:
10% of files now dated 1-1-1970 and no picture taken date, true for MP4 files only.

For these files, you can add
"-Quicktime:CreateDate<PhotoTakenTimeTimestamp"

QuoteI hope someone can help me trying to construct a command for exiftool that will import, I guess oldest date exiftool can find in the relevant Json file for the media file that matches and inserts this as creation date and/or phototaken / media created date.

I'd say the easiest thing would be to make a list of all the files where the "PhotoTakenTimeTimestamp" is greater (newer) than the "ModificationTimeTimestamp", though to be honest, I don't think there should be any of them.

You could run this command to get a list of all the files where the "ModificationTimeTimestamp" is older
exiftool -if "$PhotoTakenTimeTimestamp>ModificationTimeTimestamp" -p "$filepath" >temp.txt /path/to/files/

You would then run your original command.  Then you could change your command to replace "PhotoTakenTimeTimestamp" with "ModificationTimeTimestamp" and replace the original path with
-@ temp.txt
and exiftool will only process the files from the list.
Title: Re: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: AMAMSNL on September 05, 2022, 05:36:19 PM
Great I am going to try that and keep you posted !!!

How do i rectify this?

But the bulk of the files show a Creation Date/Time 2022:08:18 09:17 (which is the take out export date)
I don't understand how this date ends up as creation date while the json file shows entirely different dates?
While the corresponding Json file shows:

"title": "6c2f78c0-43f8-427a-af4d-06b006dc5a78.jpg",
  "description": "",
  "imageViews": "1",
  "creationTime": {
    "timestamp": "1586884805",
    "formatted": "14 apr. 2020 17:20:05 UTC"
  },
  "photoTakenTime": {
    "timestamp": "1544994008",
    "formatted": "16 dec. 2018 21:00:08 UTC"

Thanks a lot StarGeek
Title: Re: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: StarGeek on September 05, 2022, 06:05:12 PM
It helps to know what you are looking at that shows this "Creation Date/Time" when it's something other than exiftool.

I'm guessing you are looking at the Windows Properties, but not the Details tag.  Those time stamps are the file system time stamp, not the time stamps that are actually in the file.  You'll want to go to the Details tab and look for "Date Taken" for images and "Media Created" for videos.

Run this command on a file
exiftool -time:all -G -a -s file.jpg

You should see something like this
C:\>exiftool -time:all -G -a -s y:\!temp\Test4.jpg
[File]          FileModifyDate                  : 2000:01:01 02:00:00-08:00
[File]          FileAccessDate                  : 2022:09:05 14:51:30-07:00
[File]          FileCreateDate                  : 2000:01:01 12:00:00-08:00
[EXIF]          ModifyDate                      : 2018:12:16 21:00:08
[EXIF]          DateTimeOriginal                : 2018:12:16 21:00:08
[EXIF]          CreateDate                      : 2018:12:16 21:00:08

There may also be time stamps that are [IPTC] and/or [XMP].

The time stamps that start EXIF are the important ones.  Those are actually in the file.  The ones that begin [File] are the file system ones and can be a bit fragile.  This is why you should check your files with exiftool before you try to add data from the json files.  Google does not remove any data from the files.  The only time you need to import the json data is if you made changes on the Google website.

When the data is already in the file, you can copy that data to the file system time stamps with
exiftool "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" /path/to/files/

For video files, you would use CreateDate instead of DateTimeOriginal and you would add -api QuickTimeUTC
Title: Re: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: AMAMSNL on September 18, 2022, 11:46:28 AM
Thanks for your extensive answer, sorry I could not answer any sooner, my work kept me away of my media files.
I tried some of your sugesstions and seem to work, so far so good.  :)
Title: Re: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: AMAMSNL on September 19, 2022, 12:55:39 PM
I am now facing a strange problem and i have tried many options, hope you can help me out.

Sorry did not read  your previous answer carefully used this:
exiftool "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" "-api QuickTimeUTC" /path to files

THAT WORKED !!!!!! Forget below

I have a few hundred .mp4 files with accomponing HEIC.Json files.
Tried to join these with the following command:
exiftool -r -d %s -tagsfromfile "%d/%F.json" "-Quicktime:TrackCreateDate<PhotoTakenTimeTimestamp" "-DateTimeOriginal<PhotoTakenTimeTimestamp"  -ext "*" -overwrite_original -progress --ext json "/path to files
That gave an error on all files.
Then I renamed all HEIC.Json files to MP4.Json files and that seem to work, no errors all files were updated. however the date remains unchanged, equal to fileCreateDate.
I have tried many different tags such as ModifyDate, TrackCreateDate, CreationDate, CreateDate etc however the "Windows" taken date remains empty while the date in Windows explorer is the Json file creation date.
Any date is fine except FileModifyDate , FileAccessDate, FileCreateDate

Metadata looks like this for a .MP4  file name IMG_0012.Mp4 ;
---- System ----
FileModifyDate                  : 2022:09:19 18:04:46+02:00
FileAccessDate                  : 2022:09:19 18:06:45+02:00
FileCreateDate                  : 2022:08:18 09:34:16+02:00
---- QuickTime ----
CreateDate                      : 2019:10:09 08:06:52
ModifyDate                      : 2019:10:09 08:06:52
---- Track1 ----
TrackCreateDate                : 2019:10:09 08:06:52
TrackModifyDate                : 2019:10:09 08:06:53
MediaCreateDate                : 2019:10:09 08:06:52
MediaModifyDate                : 2019:10:09 08:06:53
---- Track2 ----
TrackCreateDate                : 2019:10:09 08:06:52
TrackModifyDate                : 2019:10:09 08:06:53
MediaCreateDate                : 2019:10:09 08:06:52
MediaModifyDate                : 2019:10:09 08:06:53
---- Track3 ----
TrackCreateDate                : 2019:10:09 08:06:52
TrackModifyDate                : 2019:10:09 08:06:53
MediaCreateDate                : 2019:10:09 08:06:52
MediaModifyDate                : 2019:10:09 08:06:53
---- Track4 ----
TrackCreateDate                : 2019:10:09 08:06:52
TrackModifyDate                : 2019:10:09 08:06:53
MediaCreateDate                : 2019:10:09 08:06:52
MediaModifyDate                : 2019:10:09 08:06:53
---- Keys ----
CreationDate                    : 2019:10:09 08:06:52+02:00
---- XMP-exif ----
DateTimeOriginal                : 2019:10:09 08:06:52
---- UserData ----
DateTimeOriginal                : 2019:10:09 08:06:52+02:00

Matching Json file looks like this (renamed to IMG_0012.MP4.Json, was IMG_0012.HEIC.Json :

{
  "title": "IMG_0012.HEIC",
  "description": "",
  "imageViews": "2",
  "creationTime": {
    "timestamp": "1587010719",
    "formatted": "16 apr. 2020 04:18:39 UTC"
  },
  "photoTakenTime": {
    "timestamp": "1570608412",
    "formatted": "9 okt. 2019 08:06:52 UTC"
  },
  "geoData": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "geoDataExif": {
    "latitude": 0.0,
    "longitude": 0.0,
    "altitude": 0.0,
    "latitudeSpan": 0.0,
    "longitudeSpan": 0.0
  },
  "url": "https://lh3.googleusercontent.com/Nq7QP2mAkrWoDMQxmaLqW8dbq-j0BLiCjTEQduKXdRJuxlH86cx46Ni9kLwJM6vV5VzWLS8Y4QcysXcVQU2sbnTuDbqxB-DXqod5p4Bf",
  "googlePhotosOrigin": {
    "mobileUpload": {
      "deviceType": "IOS_PHONE"
    }
  },
  "photoLastModifiedTime": {
    "timestamp": "1656650718",
    "formatted": "1 jul. 2022 04:45:18 UTC"
  }
}

Perhaps I have to change the title in the Json file, tried that but did not change anything?

You help is highly appreciated!

André
Title: Re: Correcting timestamp of media files with Json files (unzipped) Google Takeout
Post by: Phil Harvey on September 19, 2022, 01:07:39 PM
Quote from: AMAMSNL on September 19, 2022, 12:55:39 PMI have a few hundred .mp4 files with accomponing HEIC.Json files.

Shouldn't you be doing this then?:

exiftool -ext mp4 -tagsfromfile "%d%f.HEIC.Json" ...

- Phil