Hi,
I have 100G of photos in Google Photo which I've exported with Takeout. The problem is Google has all the meta data for all the photos stored in duplicate .json files. The names are the same, including the extension (i.e. "photo1.jpg.json), just with the addition of "....json".
I have been struggling for a long time now trying to figure out how to copy the data from these duplicate .json files into the associated .jpg file. It would be wonderful to move all the data to over, but the most important data I need is the PhotoTakenTimeFormatted which shows the photo taken date/time and will allow me to rename and sort all the photos by date. I have tried a number of different codes on the command line and I think I've almost figured it out.
Here's the code I'm using to try and copy the DateTimeOriginal over, but I get error messages and it isn't moving correctly:
C:\Users\jackm>exiftool -tagsfromfile "%d/%F.json" "-DateTimeOriginal<PhotoTakenTimeFormatted" FileOrDir C:\Users\jackm\Desktop\GooglePics-TEST
Warning: Error opening file - /FileOrDir.json
Error: File not found - FileOrDir
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029860384-edited.jpg.json
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029878944-edited.jpg.json
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029893645-edited.jpg.json
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029898758-edited.jpg.json
...
1 directories scanned
2310 image files updated
1808 image files unchanged
31 files weren't updated due to errors
Here's the code I'm using to try and copy all the data over, but I get error messages and it isn't pulling all the data:
C:\Users\jackm>exiftool -tagsfromfile "%d/%F.json" "-all<all" FileOrDir C:\Users\jackm\Desktop\GooglePics-TEST
Warning: Error opening file - /FileOrDir.json
Error: File not found - FileOrDir
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029860384-edited.jpg.json
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029878944-edited.jpg.json
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029893645-edited.jpg.json
Warning: Error opening file - C:/Users/jackm/Desktop/GooglePics-TEST/1386029898758-edited.jpg.json
...
1 directories scanned
2310 image files updated
1808 image files unchanged
31 files weren't updated due to errors
The DateTimeOriginal is moving when I do the -DateTimeOriginal<PhotoTakenTimeFormatted code, except the date is writing incorrectly in the jpg. I'm almost certain this is due to the UTC format of the PhotoTakenTimeFormatted being different from the .jpg. I think I need to convert the UTC first before moving it. Is there some way to build that into the same line of code?
Example:
.json file - PhotoTakenTimeFormatted: 17 Jun 2016, 01:16:59 UTC
.jpg file - DateTimeOriginal: 2016:01:16 59:00:00
The other issue is that I'm getting duplicate entries titled "photo1-edited.jpg". How do I overwrite the jpg files and not create additional copies?
I would greatly appreciate any help is solving these issues I'm stuck on.
Thank you!!
The warning messages are just for files that don't have a .json sidecar. Also, drop "FileOrDir" from the command.
The wrong date is being copied because the format is wrong. It needs to contain YYYY, mm, dd, HH, MM, SS in that order. But yours is 17 Jun 2016, 01:16:59 UTC. Converting this format is possible, but a pain mainly because of the english month, and I don't have time to show you right now. I think there may be an example in a post somewhere on this forum if you can find it.
You can add -overwrite_original to your command to prevent the backup original files from being saved.
- Phil
I'd suggest copying PhotoTakenTimeTimestamp from the json file instead. That's in epoch seconds and I believe you can use -d %s to facilitate copying it back to DateTimeOriginal.
FileOrDir was in my original command (copied from StackExchange?) as a placeholder for the file names and/or directories you wished to process. I'll check tomorrow if I was unclear about that and will fix if needed.
Also, I suggest making sure the image doesn't already have a DateTimeOriginal. If it was originally there when the file was uploaded, then it'll still be there when downloaded. The PhotoTakenTime* tags from the json file contain data that was was either copied from the original file or edited and entered on Google Photos. Google photos won't alter the data that was already in the file when uploaded.
Thank you both for the quick replies!
Yes, that was a cut and paste error keeping the FileOrDir, and it was from a Stack Overflow answer I found (https://stackoverflow.com/questions/42024255/bulk-join-json-with-jpg-from-google-takeout)
I've added the -overwrite_original and the -d %s to the code, but I keep getting these error messages saying there's "garbage at end of string in strptime". What am I doing wrong here?
C:\Users\jackm>exiftool -tagsfromfile "%d/%F.json" "-DateTimeOriginal<PhotoTakenTimeFormatted" -d %s -overwrite_original C:\Users\jackm\Desktop\GooglePics-TEST2
Warning: garbage at end of string in strptime: Oct 2015, 23:20:26 UTC in ExifIFD:DateTimeOriginal (PrintConvInv) - C:/Users/jackm/Desktop/GooglePics-TEST2/00404_2TeueD57Aq1_600x450.jpg.json
Warning: No writable tags set from C:/Users/jackm/Desktop/GooglePics-TEST2/00404_2TeueD57Aq1_600x450.jpg.json
...
1 directories scanned
0 image files updated
4148 image files unchanged
Thanks,
Jack
Quote from: jack on March 31, 2019, 12:06:27 PM
I've added the -overwrite_original and the -d %s to the code, but I keep getting these error messages saying there's "garbage at end of string in strptime". What am I doing wrong here?
As I said
Quote from: StarGeek on March 31, 2019, 04:56:38 AM
I'd suggest copying PhotoTakenTimeTimestamp from the json file instead. That's in epoch seconds and I believe you can use -d %s to facilitate copying it back to DateTimeOriginal.
Adding
-d %s does nothing if you don't switch to the tag that is formatted for use with it.
I'm sorry I'm still a bit lost with this. Are you meaning I should place the -d %s in a different spot on the same string, or should I be using something other than -tagsfromfile? If I put the -d %s on the other side of -DateTimeOriginal I still get the same errors.
You should use PhotoTakenTimeTimestamp, which is the time in epoch seconds, not PhotoTakenTimeFormatted, which is a formatted date string.
exiftool -tagsfromfile "%d/%F.json" "-DateTimeOriginal<PhotoTakenTimeTimestamp" -d %s -overwrite_original
Awesome, that worked!!
Thank you so much!!