Invalid date format

Started by dkkk, December 14, 2019, 05:34:22 PM

Previous topic - Next topic

dkkk

Hello,

I have a problem, I want to import date from a JSON file in a JPEG.

But it the JSON file the date format is  "20 mai 2019 à 16:59:42 UTC", how I can transform it for use in Exiftool ?

Thank you in advance for your answers

StarGeek

Is this from a Google Takeout?  If so, it may be better to use the seconds entry with -d "%s" option.

Otherwise it might be very complicated as you would have to translate the months into numbers.  And while I'm guessing that Mai is May, I wouldn't know the other months.
* 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).

dkkk

Thank for your reply,

Yes this is from Google Takeout
Quote from: StarGeek on December 14, 2019, 05:48:52 PM
If so, it may be better to use the seconds entry with -d "%s" option.
Sorry I'm a beginner so how I can do it

Is it possible to translate the months into numbers ?

StarGeek

Run this command on the json file to get the names of the tags.
exiftool -g1 -a -s file.json

In English, the tags you would look for are PhotoTakenTimeTimestamp and PhotoTakenTimeFormatted, but I don't know in your case.  Your command would be something like
exiftool  -TagsFromFile %d%F.json "-DateTimeOriginal<PhotoTakenTimeTimestamp" -d "%s" /path/to/jpeg/

This assumes the images are in the same directory as the json files.

Though you might double check if you actually need to do this.  The data in the json file will be the same as in the file when it was uploaded.  It will only be different if you changed it on the Google website, such as in Google Photos.
* 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

What system are you on?  If Mac or Linux there is a chance that the localized date functions will work to parse alternate-language month names with the -d option (in theory I think, although I haven't tried it myself).  You would just need to set your locale properly.

- 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 ($).

StarGeek

If that's the case then maybe this date option would work
exiftool  -TagsFromFile %d%F.json "-DateTimeOriginal<PhotoTakenTimeFormatted" -d "%d %b %Y à %H:%M:%S UTC" /path/to/jpeg/

This appears to be a different than what I get from Google Takeout.  I don't know if the à might change or not and that might give problems.
* 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).

dkkk

The name of tags are  PhotoTakenTimeTimestamp and PhotoTakenTimeFormatted.

I'm on windows.