ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: dariopnc on July 03, 2022, 06:41:54 AM

Title: Manage epoch date format
Post by: dariopnc on July 03, 2022, 06:41:54 AM
Hello everyone: I have this drone (DJI) that saved pictures and videos without properly setting date/time tags, but appends the shooting date in epoch format (seconds from 1/1/1970) to the filename.

e.g. DJI_export_1656844941.jpg (for Sun, 03 Jul 2022 10:42:21 GMT)

I haven't been able to use that to add the shooting date into the tags. I also searched the website and the forum with no luck.

In case I missed some important info, can you please ponit me to it? Otherwise can this be a new feature?

Thank you for the great job so far, btw!
Title: Re: Manage epoch date format
Post by: StarGeek on July 03, 2022, 11:44:15 AM
You have to strip away everything from the filename other than the timestamp numbers and then use the -d (-dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat) with %s as the format (see Common Date Format Codes (https://exiftool.org/filename.html#codes) for full list of codes).

Example:
C:\>exiftool -P -overwrite_original -d %s "-AllDates<${Filename;m/(\d{10})/;$_=$1}" Y:\!temp\ccc\a\DJI_export_1656844941.jpg
    1 image files updated

C:\>exiftool -time:all --system:all -G -a -s Y:\!temp\ccc\a\DJI_export_1656844941.jpg
[EXIF]          ModifyDate                      : 2022:07:03 10:42:21
[EXIF]          DateTimeOriginal                : 2022:07:03 10:42:21
[EXIF]          CreateDate                      : 2022:07:03 10:42:21
Title: Re: Manage epoch date format
Post by: dariopnc on July 22, 2022, 09:03:01 AM
Thank you!
I'll try with that

Also thank you for pointing me to the relevant documentation