Convert DateTimeOriginal with invalid format to valid format

Started by oryan_dunn, November 24, 2014, 09:52:32 PM

Previous topic - Next topic

oryan_dunn

Phil,
Thanks for maintaining the tool and this forum!

I thought about writing a quick perl script to do what I want, but figured I ask to see if exiftool could do what I need.

I've got a bunch of pictures taken with an older android, that saved the DateTimeOriginal as "yyyy/mm/dd hh:mm:ss".  I think that's ok for some tools, but windows and my new windows phone don't seem to be very happy with that.  I manually modified one of the files to "yyyy-mm-dd hh:mm:ss" and windows seemed to be happy with that.

At first glance, I didn't see options that jumped out at me to fix that, but perhaps I missed it.  I tried doing a timeshift of "0:0:0 0:0:0", but that didn't modify the file, so then I tired "0:0:0 0:0:1", and that modified the file, but kept the / in the date format.

Regards,
Ryan

Phil Harvey

Hi Ryan,

This command will fix all of the date/time tags:

exiftool -tagsfromfile @ "-all:all<time:all" DIR

where DIR is the name of a directory containing the images.

This works because ExifTool is somewhat flexible about the input date/time format, and it automatically fixes the format when writing.  The "all:all<" is necessary to force ExifTool to write the tags back to the same locations where they were found.

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

oryan_dunn

Thanks Phil, I'll give this a shot.

I'm curious, if it writes back in a proper format, why did me adding 1s to the time not cause the output file to be written in a correct exif format?

Phil Harvey

I can answer this if you give me the exact command and tell me what version of ExifTool you are using.

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

oryan_dunn

I'm at work, and I ran this at home (and I likely closed the command window, and I don't think Windows has a command history like bash).

It's the latest version 9.76, I believe.

I think I used
exiftool.exe -DateTimeOriginal+="0:0:0 0:0:1" file.jpg

Phil Harvey

Ah, sorry.  I missed that you were talking about shifting a date/time value.  You're right, the reformatting is not done when shifting a date/time, only when writing a new value.

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

oryan_dunn

Ok, that makes sense why it didn't work then.

For invalid formats, can the tool parse "mm/dd/yyyy hh:mm:ss AM|PM"?  I've found I've got some pictures in that format as well.  Not as many, so if I had to manually fix those, it wouldn't be a huge issue.

Phil Harvey

No, it won't recognize AM/PM.  See FAQ 5 for a description of input date/time formats.

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