How to fix wrong time separator (dot)?

Started by yegiv, December 12, 2023, 05:40:11 AM

Previous topic - Next topic

yegiv

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?

greybeard

Exiftool has an option to change date format in commands: -d "%d.%m.%Y %H.%M.%S"

yegiv

#2
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?

StarGeek

What is the output of this command?
exiftool -time:all -G1 -a -s file.jpg
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

yegiv

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                      :     :  :     :  :

StarGeek

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
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

greybeard

Apologies for confusing things - I guess the date format (-d) just formats the output when the internal date is correctly stored.

StarGeek

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

#8
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 with this same problem.

Read here for details about the API StrictDate option.

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

yegiv

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!

StarGeek

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
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype