Incorrect Date Format

Started by BigBadWolf, May 06, 2017, 06:13:20 PM

Previous topic - Next topic

BigBadWolf

I have tried searching but lo luck so far. I am working with old files that do not have standard format for the timestamp in DateTimeOriginal.

Date/Time Original              : 04/07/2003 00:09:40
Create Date                     : 04/07/2003 00:09:40


Is there a way to correct it?

BigBadWolf

Forgot to mention that file dates appear to be correct, and just Create Date and Date Time Original are in the wrong format.

File Modification Date/Time     : 2003:04:16 09:52:06-07:00
File Access Date/Time           : 2017:05:05 23:49:53-07:00
File Creation Date/Time         : 2017:05:05 23:49:53-07:00

StarGeek

If you're sure that the FileModifyDate is correct as in your second listing, then you could use
exiftool -P "-alldates<FileModifyDate" FileOrDir

I included -P in this command so as not to change any of the file system timestamps just in case.

Otherwise, you could try this.  I haven't tested it since I can't replicate the mistake in your data.
exiftool "-alldates<${DateTimeOriginal;s/(\d\d)\/(/d/d)\/(\d{4}) (.*)/$3:$1:$2 $4/" FileOrDir

That's also assuming that you actually did take pictures about midnight as shown in your first post.
* 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).

BigBadWolf

#3
Unfortunately, filemodifydate is not correct, and I confirmed that DateTimeOriginal is correct.

I had to add -m to the line to ignore the warning message
exiftool "-alldates<${DateTimeOriginal;s/(\d\d)\/(/d/d)\/(\d{4}) (.*)/$3:$1:$2 $4/" -m "file or DIR"
but the result is not what I expect

Before:
Date/Time Original              : 04/07/2003 00:09:40
Create Date                     : 04/07/2003 00:09:40


After:
Date/Time Original              : 2003:00:09 40:00:00
Create Date                     : 2003:00:09 40:00:00


message:
Warning: Error rebuilding maker notes (may be corrupt)

StarGeek

Sorry, my mistake.  I forgot the closing brace.  The part of the line with $4 should be $4/}

I also found a several similar files in Phil's ExifTool Meta Information Repository (an HTC, ImpressCam, Rollei, SamsungDigimax, and UMAX) so I was able to test it.  In this case, even though there were minor errors, it was still able to write correctly without the -m option.

C:\>exiftool -alldates "X:\!temp\NewDirectory\SamsungDigimax350SE.jpg"
Date/Time Original              : 2004/09/18 15:17:47
Create Date                     : 2004/09/18 15:17:47
Modify Date                     : 2004/09/18 15:17:47

C:\>exiftool -P -overwrite_original "-alldates<${DateTimeOriginal;s/(\d\d)\/(/d/d)\/(\d{4}) (.*)/$3:$1:$2 $4/}" "X:\!temp\NewDirectory\SamsungDigimax350SE.jpg"
Warning: [minor] Unrecognized MakerNotes - X:/!temp/NewDirectory/SamsungDigimax350SE.jpg
Warning: [minor] Maker notes could not be parsed - X:/!temp/NewDirectory/SamsungDigimax350SE.jpg
    1 image files updated

C:\>exiftool -alldates "X:\!temp\NewDirectory\SamsungDigimax350SE.jpg"
Date/Time Original              : 2004:09:18 15:17:47
Create Date                     : 2004:09:18 15:17:47
Modify Date                     : 2004:09:18 15:17:47
* 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).

BigBadWolf

Great! Thank you!

With slight modification, it worked perfectly.
exiftool "-alldates<${datetimeoriginal;s/(\d{2})\/(\d{2})\/(\d{4}) (.*)/$3:$1:$2 $4/}" "file or DIR"
Date/Time Original              : 2003:04:07 00:09:40
Create Date                     : 2003:04:07 00:09:40


BTW, looks like pictures were taken with DIGIMAX 350SE.

Phil Harvey

The reformatting shouldn't be necessary.  ExifTool is smart enough to figure it out with this command:

exiftool "-alldates<datetimeoriginal" "file or DIR"

See FAQ 5 for why this works.

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

BigBadWolf

Quote from: Phil Harvey on May 06, 2017, 10:07:18 PM
The reformatting shouldn't be necessary.  ExifTool is smart enough to figure it out with this command:

exiftool "-alldates<datetimeoriginal" "file or DIR"

See FAQ 5 for why this works.

- Phil

Phil, I tried that, and the date 04/07/2003 00:09:40 came out as 2003:00:09 40:00:00 instead of 2003:04:07 00:09:40. It seems like time was converted into date, and month and day was dropped.

Phil Harvey

RIght.  Sorry.  I was looking at the wrong example:

Quote from: StarGeek on May 06, 2017, 08:15:03 PM
Date/Time Original              : 2004/09/18 15:17:47

I didn't realize the date was in the wrong order in your files.

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

StarGeek

Sorry, my mistake.  I was so excited to find files with incorrect DateTimeOriginal that I didn't notice that they weren't as bad as BigBadWolf's files.
* 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).