ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Jan.Steinman on April 07, 2024, 11:15:11 PM

Title: Copying tags between parallel directory structures?
Post by: Jan.Steinman on April 07, 2024, 11:15:11 PM
I keep thinking this should be a common and simple thing to do, and I've searched the man page and this forum for examples, but I can't quite wrap my head around something that should be fairly simple: copying tag values between same-named files between two parallel directory structures.

I have two directories, "a" and "b". (Literally! I made "a" and "b" symlinks to the actual directories for simplicity. "b" is actually a backup copy of "a".)

Within these top directories are one- or two-levels of parallel sub-directories, eventually containing identically-named files.

exiftool -r -TagsFromFile 'b/%f' -GPSLatitude -GPSLongitude a
Is it really that simple, or am I missing something? I don't want to try it and screw things up!

Thanks!
Title: Re: Copying tags between parallel directory structures?
Post by: StarGeek on April 07, 2024, 11:58:36 PM
%f is only the base filename and does not include the extension.  You can either include it (and the dot) with %f.%e or use %F, which is the full filename.

It will get more complex if you have subdirectories.  In that case you will have to include the %d variable for the directory, but it would require some editing.

See the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) for details on the percent variables and Writing "FileName" and "Directory" tags (https://exiftool.org/filename.html) for more examples.

But basically, yes, your command is almost correct.  The one major thing that's missing is the GPS Reference directions.  GPS coordinates are divided into the actual numbers and then the reference direction, N/S/E/W/Above/Below sea level.

Assuming that you do have subdirectories, and you have CDed to the directory that contains both directory a and b, you command would look like this (%:1d removes the top level of the path, in this case the a)
exiftool -r -TagsFromFile 'b/%:1d/%f.%e' -GPSLatitude -GPSLatitudeRef -GPSLongitude -GPSLongitudeRef a

or you could shorten it with a wildcard to copy both the coordinates and reference at once
exiftool -r -TagsFromFile 'b/%:1d/%f.%e' -GPSLatitude* -GPSLongitude* a

Title: Re: Copying tags between parallel directory structures?
Post by: Jan.Steinman on April 10, 2024, 09:01:05 PM
Thanks so much! Worked like a charm.