Hello
I've added gps coordinates to many of my photos. But I didn't add GPSDateTime.
Now I'm building some gpx files or wpt gpx files with gpx.fmt or gpx_wpt.fmt files (thank you for providing these files ! )
but some apps cant'use wpt files without dates where <time> </time> is empty (gpxsee.exe)
I used
exiftool "-GPSDateStamp<EXIF:DateTimeOriginal" "-GPSTimeStamp<EXIF:DateTimeOriginal" "-XMP:GPSDateTime<EXIF:DateTimeOriginal" file.jpg
That's ok but, i would like to substract 1 (or 2) hours before writing gpsDateStamp and then create a args file or modify a fmt file ...
4 methods ?:
- use 2 steps : 1st use the same args, and then another step to substract 1 hour to each field
- use ${EXIF:DateTimeOriginal; how to substract one hour ? } as source data
- modify my gpx_wpt.fmt file with :
if !Defined $gpstimestamp ...
- perhaps use a config file ?
What is the most robust, elegant or reasonable method ?
((I much prefer the 3rd method but don't know the right syntax for this )
Thanks
Translated from french
gpx_wpt.fmt
#[HEAD]<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
#[HEAD]<gpx version="1.1"
#[HEAD] creator="ExifTool $ExifToolVersion"
#[HEAD] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
#[HEAD] xmlns="http://www.topografix.com/GPX/1/1"
#[HEAD] xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
#[IF] $gpslatitude $gpslongitude
#[BODY]<wpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY] <ele>$gpsaltitude#</ele>
#[BODY] <time>${gpsdatetime#;DateFmt("%Y-%m-%dT%H:%M:%SZ")}</time>
#[BODY] <name>$filename</name>
#[BODY] <desc>$city</desc>
#[BODY] <link href="$directory/$filename"/>
#[BODY] <sym>Scenic Area</sym>
#[BODY] <extensions>
#[BODY] <gpxx:WaypointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
#[BODY] <gpxx:DisplayMode>SymbolAndName</gpxx:DisplayMode>
#[BODY] </gpxx:WaypointExtension>
#[BODY] </extensions>
#[BODY]</wpt>
#[TAIL]</gpx>
I would check your files to see if the OffsetTime* exists, as if they do the command will be much simpler
exiftool -G1 -a -s "-OffsetTime*" file.jpg
If OffsetTime* tags exist, then all you need to do is
exiftool "-GPS*Stamp<SubSecDateTimeOriginal" "-GPSDateTime<SubSecDateTimeOriginal" /path/to/files/
Because SubSecDateTimeOriginal includes the time zone, exiftool will automatically adjust the time to UTC when writing the GPS time stamps.
If it is not, then I would probably go with
exiftool "-GPSDateStamp<${DateTimeOriginal}-01:00" "-GPSTimeStamp<${DateTimeOriginal}-01:00" "-XMP:GPSDateTime<${DateTimeOriginal}-01:00" file.jpg
or with the GlobalTimeShift option (https://exiftool.org//exiftool_pod.html#globalTimeShift-SHIFT)
exiftool -GlobalTimeShift -01:00 "-GPSDateStamp<DateTimeOriginal" "-GPSTimeStamp<DateTimeOriginal" "-XMP:GPSDateTime<DateTimeOriginal" file.jpg
Thanks for these solutions. I'm using some of them now
I'm working on a software with the informations you gave
None of my cameras write the OffsetTime tag, but I can see this :
[File] FileModifyDate : 2025:04:16 20:35:48+02:00
[File] FileAccessDate : 2025:04:16 20:35:49+02:00
[File] FileCreateDate : 2025:03:06 15:06:35+01:00
Does it mean that offset can be found here and perhaps used to write offset* tags ?
Here, in april, time is utc+2 and in march 03rd, time is utc + 1
It's probably not best to copy from the file system time stamp at first, because there's nothing to stop a file from having an embedded time stamp during Daylight savings and a file system that isn't or vice versa.
You could do a two-step procedure by first copying an embedded time stamp such as DateTimeOriginal to one of the file system time stamps, and then copying that value into the GPS time stamp. In this case, the OS figures out the time zone for you automatically.
First
exiftool "-FileModifyDate<DateTimeOriginal" /path/to/files/
then this, adding the OffsetTime* tags in the same command
exiftool "-GPS*Stamp<FileModifyDate" "-GPSDateTime<FileModifyDate" "-OffsetTime*<FileModifyDate" /path/to/files/
The previous command that used the GlobalTimeShift option would also work in one shot without needing the OffsetTime* tags, but in that case you have to figure out whether you need a -1 or -2.
Quote from: StarGeek on April 16, 2025, 04:10:55 PMIt's probably not best to copy from the file system time stamp at first, because there's nothing to stop a file from having an embedded time stamp during Daylight savings and a file system that isn't or vice versa.
Right
For most of the files that have lost their DateTimeOriginal, I used to use FileModifyDate instead, but I've noticed also that some files have an updated FileModifyDate despite my precautions not to change it.
So, when DateTimeOriginal exists, your solution is wondeful.
This is the args file :
# Sur une idee geniale de StarGeek du forum exiftool.
#
-P
-if
$DateTimeOriginal
-FileModifyDate<DateTimeOriginal
-GPSDateStamp<FileModifyDate
-GPSTimeStamp<FileModifyDate
-GPSDateTime<FileModifyDate
-OffsetTime*<FileModifyDate
Thank you very much
Quote from: elhiero on April 16, 2025, 05:15:01 PMThis is the args file :
# Sur une idee geniale de StarGeek du forum exiftool.
#
-P
-if
$DateTimeOriginal
-FileModifyDate<DateTimeOriginal
-GPSDateStamp<FileModifyDate
-GPSTimeStamp<FileModifyDate
-GPSDateTime<FileModifyDate
-OffsetTime*<FileModifyDate
This args file isn't doing what you think it is. The
DateTimeOriginal is being copied to the
FileModifyDate, but the original
FileModifyDate is what is copied to the other time stamps. It needs to be two separate steps to work correctly.
You could change it to this
# Sur une idee geniale de StarGeek du forum exiftool.
#
-P
-if
$DateTimeOriginal
-FileModifyDate<DateTimeOriginal
-execute
-P
-GPSDateStamp<FileModifyDate
-GPSTimeStamp<FileModifyDate
-GPSDateTime<FileModifyDate
-OffsetTime*<FileModifyDate
But you need to make sure that your command includes the
-Common_Args option (https://exiftool.org/exiftool_pod.html#common_args) with the names of the files to be processed after it. The
-P (
-preserve) option (https://exiftool.org/exiftool_pod.html#P--preserve) needs to be duplicated, or it can be moved to the command line after the
-Common_Args exiftool -@ MyArgs.args -Common_Args /path/to/files/
I think this argfile can be simplified to
# Sur une idee geniale de StarGeek du forum exiftool.
#
-FileModifyDate<DateTimeOriginal
-execute
-P
-GPSDateStamp<FileModifyDate
-GPSTimeStamp<FileModifyDate
-GPSDateTime<FileModifyDate
-OffsetTime*<FileModifyDate
1. The -if isnt necessary because FileModifyDate won't be written if DateTimeOriginal doesn't exist.
2. The first -P doesn't make sense because you are writing FileModifyDate.
- Phil