Author Topic: Conditional Merge from XMP -> Raw Camera files.  (Read 133 times)

clem

  • Jr. Member
  • **
  • Posts: 25
Conditional Merge from XMP -> Raw Camera files.
« on: July 27, 2020, 06:26:46 PM »
I've discovered that my workflow with tagging files with GPS coordinates has been incomplete. While I thought I was tagging the individual files, it appears that the application used was writing to XMP files alone and not the raw camera file.

I would like to sic exiftool on a series of nested folders with the files to check and write the missing data directly into the raw file. Due to the number of files involved, I'd rather have it done conditionally…

Only files that are missing the data AND have a paired XMP file would be remade/appended. I'd like to keep all time values as originally recorded on the camera.

Doing an A:B on a file that was 'missed' by having a side-car / XMP file created instead of its data being modified, I've deduced that I'd like to get the following data from the side-car XMP files into the raw file. These values exist in the XMP side-car, but not in the CR2/NEF/DNG.


Location Created City         
Location Created Country Name 
Location Created Province State
Creator                       
Rights                         
Country                       
State
City                           
Province-State                 
Country-Primary Location Name 
GPS Version ID                 
GPS Altitude Ref               
GPS Time Stamp                 
GPS Map Datum                 
GPS Date Stamp                 
GPS Altitude                   
GPS Date/Time                 
GPS Latitude                   
GPS Longitude                 
GPS Latitude Ref               
GPS Longitude Ref             


There are other fields that seem to be created reflecting time of modification but I'd like them to be the same time as the [Date/Time Original]

Metadata Date
Date Created                   
Time Created                   
Date/Time Created             


What steps can I take to make this happen?

thank you!

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3951
Re: Conditional Merge from XMP -> Raw Camera files.
« Reply #1 on: July 27, 2020, 06:48:24 PM »
This is basically a specialized version of XMP sidecars example 15.  All it would require is adding -wm cg and maybe some other tweaks to make sure the data goes where you want.
exiftool -wm cg --ext xmp -tagsfromfile %d%f.xmp -TAG1 -TAG2 -TAG3 /path/to/files/

This -wm (writemode) option will not overwrite any existing tags, only create new ones that don't exist.  The -ext (extension) option has two dashes, so that XMP files are not processed (don't want to try and copy the XMP sidecar back onto itself).  From there, just list the tags you want copied.

The one place you might need to tweak things would be if you wanted tags to go someplace else other than into the same XMP location.  For example, the sidecar file should have the GPS reference as part of the Latitude/Longitude (i.e. there shouldn't be an XMP:GPSLatitudeRef, but some programs create this).  Normally, you would want this copied to the GPSLatitude/Longitude tags that are part of the EXIF group.  In a case like this, you would want to use something like this, which will fill both the number portion and the Ref direction at the same time.
"-GPSLatitude*<GPSLatitude" "-GPSLongitude*<GPSLongitude"
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

clem

  • Jr. Member
  • **
  • Posts: 25
Re: Conditional Merge from XMP -> Raw Camera files.
« Reply #2 on: July 27, 2020, 08:16:49 PM »
Thank you for giving me a good starting point!

Will this be a conditional file read and write with the -wm cg flag where it will not create tags etc. if they already exist?

thank you!

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3951
Re: Conditional Merge from XMP -> Raw Camera files.
« Reply #3 on: July 28, 2020, 05:08:59 PM »
The -wm cg option will simply not overwrite any existing tags.  See the docs for more details.

On the downside, it also won't add list type tags such as Keywords if they already exist.

This is my go to option any time I'm not sure if there's already data in a group of files.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.