News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Copying GPS date/time to other date fields

Started by BarCar, May 01, 2014, 08:29:08 AM

Previous topic - Next topic

BarCar

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.

Phil Harvey

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

BarCar

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!

Phil Harvey

The documentation explains how, but not why.  The reason is that "=" would break assignments like "-currency=$US".  Maybe this will help you remember.

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