Copy gps data from xmp files to Canon CR2 files

Started by Ex-Lrc-User, November 01, 2024, 11:18:56 AM

Previous topic - Next topic

Ex-Lrc-User

I have had LrC write xmp files to the file system for about 10,000 Canon CR2 files and would now like to use exiftool to recursively write the GPS data (especially gpslatitude, gpslongitude and gpsaltitude) from the XMP files to the Canon CR2 files. The original time stamps should be retained and no copies created. Of course, I first test the command with a smaller number of copies. I have created the following exiftool command:

exiftool -r -P -overwrite_original -ext xmp -tagsFromFile @ -gpslatitude -gpslongitude -gpsaltitude -ext cr2 /pathtofolder


What do you think? Is there something wrong with it, or can it be improved? Should I transfer more GPS metatags?

StarGeek

The EXIF GPS tags are split into two separate tags. The numeric coordinates and the reference directions N/S/E/W/Above/Below. You must copy the data to both of them.
"-GPSLatitude*<GPSLatitude" "-GPSLongitude*<GPSLongitude" "-GPSAltitude*<GPSAltitude#"
This uses a wild card to fill out both coordinates and the reference direction at the same time. Note that you need the trailing # for GPSAltitude

This change is for Windows CMD. It will work on Mac/Linux as well, but it would be a good habit to use single quotes instead of double quotes for those systems.

Your -TagsFromFile option is also incorrect. The parameter directly following -TagsFromFile is the name of the file to copy from. The @ sign indicates that you are copying from the same file. So this command copies from the XMP files back into the XMP files and the CR2 files back into the CR2 files.

You also need to remove -ext xmp. You don't want to add anything back into the XMP files. You only want to process the CR2 files, so you only need -ext CR2.

I would also include the GPS time stamps.

exiftool -r -P -overwrite_original -tagsFromFile %d%f.xmp "-GPSLatitude*<GPSLatitude" "-GPSLongitude*<GPSLongitude" "-GPSAltitude*<GPSAltitude#" "-GPS*Time<GPSDateTime" -ext cr2 /path/to/files/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Ex-Lrc-User

Hi StarGeek,
many thanks for the precise explanations and corrections!
In the meantime, I have tested the command as you suggested with a small number of copies of my CR2 files with the corresponding XMP files. The command ran recursively without errors and all the CR2 files now contain the desired GPS data from the XMP sidecar files. I then viewed the modified CR2 files with the Canon software "Digital Photo Professional 4" and checked whether they are considered valid: they are   :)

Is there anything else I need to consider when I run the command on my image archive with approx. 80,000 photos - of which around 10,000 have an XMP file? Can there be memory problems? It's a Mac with 64 GB RAM and exiftool version 13.
Can ExifTool also write a log file about the files it has changed or if something went wrong?
ExifTool is so brilliant!

StarGeek

Quote from: Lrc-User on November 02, 2024, 09:16:51 AMIs there anything else I need to consider when I run the command on my image archive with approx. 80,000 photos - of which around 10,000 have an XMP file? Can there be memory problems? It's a Mac with 64 GB RAM and exiftool version 13.

I've run commands over a couple of hundred thousand files before on Windows without problems. A Mac is even less likely to have memory problems than Windows command line.

QuoteCan ExifTool also write a log file about the files it has changed or if something went wrong?

You can use the -efile option to save problem filenames to a file. And add the -progress option and redirect the output into a file for everything else.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Ex-Lrc-User

Hi StarGeek, today I successfully used ExifTool to write the GPS data from around 10,000 Lightroom XMP files to the Canon CR2 RAW files. Thanks again for your support :-)
For all those who want to use the command: be careful, test beforehand and specify the path exactly. If parts of the path are missing - e.g. due to a copy&paste error at the end of the path - the actual path is higher in the file hierarchy than desired. Exiftool will graze off everything due to the -r option.