ExifTool Forum

ExifTool => Newbies => Topic started by: BarCar on May 01, 2014, 08:29:08 AM

Title: Copying GPS date/time to other date fields
Post by: BarCar on May 01, 2014, 08:29:08 AM
I've got some files with GPS date/times but no other date tags. I'm trying to take the GPS date and time and write it to other date tags.

I started out with this:

exiftool.exe -r -v -if "not defined $DateTimeOriginal" -if "defined $gps:gpsdatestamp" -ext jpg -ext png -DateTimeOriginal="$gps:gpsdatestamp $gps:gpstimestamp" -CreateDate="$gps:gpsdatestamp $gps:gpstimestamp" -ModifyDate="$gps:gpsdatestamp $gps:gpstimestamp" "-FileModifyDate<DateTimeOriginal" "somefolder"

But get errors like this:

Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal (PrintConvInv)
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:CreateDate (PrintConvInv)
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in IFD0:ModifyDate (PrintConvInv)


Printing out the same gives shows sub-second accuracy in the GPS time:

exiftool -p "$gps:gpsdatestamp $gps:gpstimestamp" "somefile.jpg"
2012:04:27 11:12:31.53


So I tried truncating the GPS timestamp:

exiftool -p "$gps:gpsdatestamp ${gps:gpstimestamp;s/\..*//}" "somefile.jpg"
2012:04:27 11:12:31


Which looked like the correct EXIF EXIF "YYYY:mm:dd HH:MM:SS" format. So I tried:

exiftool.exe" -r -v -if "not defined $DateTimeOriginal" -if "defined $gps:gpsdatestamp" -ext jpg -ext png "-DateTimeOriginal=$gps:gpsdatestamp ${gps:gpstimestamp;s/\..*//}" "-CreateDate=$gps:gpsdatestamp ${gps:gpstimestamp;s/\..*//}" "-ModifyDate=$gps:gpsdatestamp ${gps:gpstimestamp;s/\..*//}" "-FileModifyDate<DateTimeOriginal" "somefolder"

But this gives the same errors as the first attempt.

Any ideas what I'm doing wrong? Thanks in advance.
Title: Re: Copying GPS date/time to other date fields
Post by: Phil Harvey on May 01, 2014, 08:53:09 AM
Your commands aren't working because you want to copy the value from another tag (with "<") instead of assign a value ("=").

Also, you should take advantage of the Composite GPSDateTime tag for this (that is what it is for):

exiftool -if "not defined $DateTimeOriginal" "-datetimeoriginal<gpsdatetime" ...

And setting FileModifyDate won't work the way you are doing it because DateTimeOriginal doesn't exist.  Instead, you must set this the same way that you did with DateTimeOriginal.

- Phil
Title: Re: Copying GPS date/time to other date fields
Post by: BarCar on May 01, 2014, 09:00:27 AM
Thanks Phil.

I managed to convince myself that I could only use "<" with a direct tag copy (no manipulation). Using the GPS composite tag makes that issue irrelevant but I'll need to go back and read more about  "=" versus "<" to get it clear in my head.

Much appreciated!
Title: Re: Copying GPS date/time to other date fields
Post by: Phil Harvey on May 01, 2014, 09:45:51 AM
The documentation explains how, but not why.  The reason is that "=" would break assignments like "-currency=$US".  Maybe this will help you remember.

- Phil