Conditionally copy GPS tags to XMP from RAW's

Started by msbc, December 22, 2014, 08:18:40 PM

Previous topic - Next topic

msbc

I use a camera mounted GPS to tag my Nikon NEF's. I'd like to copy this GPS tags into the XMP sidecars, if it's not already there. Have read a lot of forum posts but am unable to get this to work.

Here's the code I have:
exiftool -tagsfromfile %f.NEF -gps:all -if "not \$gpsposition" -ext XMP .

Testing this on a folder with 3 NEF's - one of the XMPs has GPS tags so I only expect 2 XMPs to be updated. I get this output:
12:15 ~/Pictures/Test $ exiftool -v2 -tagsfromfile %f.NEF -gps:all -if "not \$gpsposition" -ext XMP .
-------- ./MSC_2014-02-01_1866.XMP (failed condition)
======== ./MSC_2014-02-01_1886.XMP
Setting new values from MSC_2014-02-01_1886.NEF
Writing GPS:GPSVersionID
Writing GPS:GPSTimeStamp
Writing GPS:GPSSatellites
Writing GPS:GPSMapDatum
Writing GPS:GPSLongitudeRef
Writing GPS:GPSLongitude
Writing GPS:GPSLatitudeRef
Writing GPS:GPSLatitude
Writing GPS:GPSDateStamp
Writing GPS:GPSAltitudeRef
Writing GPS:GPSAltitude
Rewriting ./MSC_2014-02-01_1886.XMP...
  FileType = XMP
  MIMEType = application/rdf+xml
Nothing changed in ./MSC_2014-02-01_1886.XMP
======== ./MSC_2014-02-01_1893.XMP
Setting new values from MSC_2014-02-01_1893.NEF
Writing GPS:GPSVersionID
Writing GPS:GPSTimeStamp
Writing GPS:GPSSatellites
Writing GPS:GPSMapDatum
Writing GPS:GPSLongitudeRef
Writing GPS:GPSLongitude
Writing GPS:GPSLatitudeRef
Writing GPS:GPSLatitude
Writing GPS:GPSDateStamp
Writing GPS:GPSAltitudeRef
Writing GPS:GPSAltitude
Rewriting ./MSC_2014-02-01_1893.XMP...
  FileType = XMP
  MIMEType = application/rdf+xml
Nothing changed in ./MSC_2014-02-01_1893.XMP
    1 directories scanned
    1 files failed condition
    0 image files updated
    2 image files unchanged
- Mark

Phil Harvey

Hi Mark,

The problem is that you can't write EXIF GPS tags to an XMP file.  Here is the proper way to translate EXIF GPS to XMP:

exiftool -tagsfromfile %f.NEF -@ gps2xmp.args -if "not \$gpsposition" -ext XMP .

Attached is the gps2xmp.args file which is included in the full ExifTool distribution.

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