ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: yegiv on December 12, 2023, 05:40:11 AM

Title: How to fix wrong time separator (dot)?
Post by: yegiv on December 12, 2023, 05:40:11 AM
I have a lot of photos from old phone, which exif date and time format is "30.11.2008 00.48.17", time separated by dot not colon. So, exiftool says "Warning: Month '17' out of range 1..12" for example.
How to fix it?
Title: Re: How to fix wrong time separator (dot)?
Post by: greybeard on December 12, 2023, 07:58:23 AM
Exiftool has an option to change date format in commands: -d "%d.%m.%Y %H.%M.%S"
Title: Re: How to fix wrong time separator (dot)?
Post by: yegiv on December 12, 2023, 08:40:55 AM
Quote from: greybeard on December 12, 2023, 07:58:23 AM-d "%d.%m.%Y %H.%M.%S"

Thank you. I tried to convert dates with command:
exiftool "-CreateDate<DateTimeOriginal" -d "%d.%m.%Y %H.%M.%S" D:\photos\*
but got message:
Warning: No writable tags set fromand all files remained unchanged.
what is wrong?
Title: Re: How to fix wrong time separator (dot)?
Post by: StarGeek on December 12, 2023, 10:41:26 AM
What is the output of this command?
exiftool -time:all -G1 -a -s file.jpg
Title: Re: How to fix wrong time separator (dot)?
Post by: yegiv on December 12, 2023, 11:40:33 AM
Quote from: StarGeek on December 12, 2023, 10:41:26 AMWhat is the output of this command?
exiftool -time:all -G1 -a -s file.jpg

[System]        FileModifyDate                  : 2016:12:24 14:45:32+01:00
[System]        FileAccessDate                  : 2023:12:12 00:00:00+01:00
[System]        FileCreateDate                  : 2023:12:12 17:39:35+01:00
[ExifIFD]       DateTimeOriginal                : 01.06.2009 21.52.38
[ExifIFD]       CreateDate                      :     :  :     :  :
Title: Re: How to fix wrong time separator (dot)?
Post by: StarGeek on December 12, 2023, 12:13:14 PM
You'll want to fix the DateTimeOriginal as well as copying to CreateDate Try this.  If you're using Mac/Linux, change the double quotes to single quotes.  On Windows, use CMD instead of PowerShell.
exiftool "-AllDates<${DateTimeOriginal;s/^(\d\d)\.(\d\d)\.(\d{4})/$3:$2:$1/}" /path/to/files/

Example
C:\>exiftool -G1 -a -s -alldates y:\!temp\Test4.jpg
[ExifIFD]       DateTimeOriginal                : 01.06.2009 21.52.38

C:\>exiftool -P -overwrite_original "-AllDates<${DateTimeOriginal;s/^(\d\d)\.(\d\d)\.(\d{4})/$3:$2:$1/}" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -alldates y:\!temp\Test4.jpg
[ExifIFD]       DateTimeOriginal                : 2009:06:01 21:52:38
[ExifIFD]       CreateDate                      : 2009:06:01 21:52:38
[IFD0]          ModifyDate                      : 2009:06:01 21:52:38
Title: Re: How to fix wrong time separator (dot)?
Post by: greybeard on December 12, 2023, 12:34:09 PM
Apologies for confusing things - I guess the date format (-d) just formats the output when the internal date is correctly stored.
Title: Re: How to fix wrong time separator (dot)?
Post by: StarGeek on December 12, 2023, 01:46:12 PM
Quote from: greybeard on December 12, 2023, 12:34:09 PMI guess the date format (-d) just formats the output when the internal date is correctly stored.

Yes, I had to double-check that.
Title: Re: How to fix wrong time separator (dot)?
Post by: Phil Harvey on December 12, 2023, 09:35:13 PM
Quote from: greybeard on December 12, 2023, 12:34:09 PMApologies for confusing things - I guess the date format (-d) just formats the output when the internal date is correctly stored.

No.  This would have worked but you need to set -api strictdate=0, otherwise improper date/time values aren't copied.

With -api strictdate=0 the extracted invalid date/time is passed through unformatted, and the -d reformatting is applied to convert the value back when writing.

We recently had another topic (https://exiftool.org/forum/index.php?msg=83054) with this same problem.

Read here (http://exiftool.org/ExifTool.html#StrictDate) for details about the API StrictDate option.

- Phil
Title: Re: How to fix wrong time separator (dot)?
Post by: yegiv on December 13, 2023, 08:49:54 AM
Quote from: StarGeek on December 12, 2023, 12:13:14 PMexiftool "-AllDates<${DateTimeOriginal;s/^(\d\d)\.(\d\d)\.(\d{4})/$3:$2:$1/}" /path/to/files/
Such good advice! Thank you so much, everything works well!
Title: Re: How to fix wrong time separator (dot)?
Post by: StarGeek on December 13, 2023, 10:45:43 AM
Just to show the results of greybeard's command with Phil's recommendation
C:\>exiftool -time:all --system:all -G -a -s y:\!temp\Test4.jpg
[EXIF]          DateTimeOriginal                : 30.11.2008 00.48.17

C:\>exiftool -api strictdate=0 -d "%d.%m.%Y %H.%M.%S" "-CreateDate<DateTimeOriginal" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -time:all --system:all -G -a -s y:\!temp\Test4.jpg
[EXIF]          DateTimeOriginal                : 30.11.2008 00.48.17
[EXIF]          CreateDate                      : 2008:11:30 00:48:17