How to search and replace on GPS data

Started by jacklail, August 13, 2024, 10:10:14 AM

Previous topic - Next topic

jacklail

How do you use an if statement to search and replace GSP data.

For example, if you want to find 22.22222 in -gpslatitude and replace it with 33.33333, how do you do that?

It doesn't seem as straight forward as searching in the -description or -keywords fields.

-- Jack Lail




StarGeek

Your command would be something like this
exiftool -if "$GPSLatitude#==22.22222" -GPSLatitude=33.33333 /path/to/files/

The hashtag #, which is a shortcut for the -n (--printConv) option, is needed directly after GPSLatitude because by default, exiftool will list GPS coordinates in Degrees°Minutes'Seconds". Without it, you would need to search for "22 deg 13' 19.99" N" and use the Perl string comparison of eq instead of the numeric comparison of ==.

Also remember, GPS coordinates are saved as three fractional numbers, not as exact decimals, so there will always be floating point conversion errors. It can be useful to use the -c (-coordFormat) option to set how many decimals you want to use.

Or you rather than look for an exact coordinate, you could use greater than/less than to capture a range
exiftool -if "$GPSLatitude#>22.22221 and $GPSLatitude#<22.22223" -GPSLatitude=33.33333 /path/to/files/

For a more accurate search within a range, you can use the command in this post.
"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

jacklail