Help with missing exif data

Started by GoodKarma, November 15, 2022, 12:11:27 PM

Previous topic - Next topic

GoodKarma

I currently use the following command

exiftool -tagsfromfile %d%f.JPG '-GPS:GPSImgDirection<XMP:Yaw' -ext JPG 'E:\TEMP\phll_test\' '-GPS:GPSImgDirectionRef=Magnetic North'

which is a combination of 2 commands. (is the most efficient way of doing this ).

However, I would like to use this in combination with, if possible

exiftool -filename -r -if '(not $gpsimagedirection)' *.*
which prints a list of all files missing the gpsimgdirection tag

can this be done?

Phil Harvey

I have a few questions.

1. Do you want to process all files with the 2nd command but only JPG files with the first command?

2. Do you want to print the name if GPSImgDirection doesn't exist only after it has been copied from XMP:Yaw?

Assuming only JPG images for the 2nd command and you want to test GPSImgDirection after running the first command, then something like this may work:

exiftool -tagsfromfile %d%f.JPG '-GPS:GPSImgDirection<XMP:Yaw' -ext JPG 'E:\TEMP\phll_test\' '-GPS:GPSImgDirectionRef=Magnetic North' -if 'defined $GPS:GPSImgDirection or defined $XMP:Yaw' -efile5 file_list.txt

This will process only files which already have XMP:Yaw or GPS:GPSImgDirection, and will write the names of other JPG files (or files which had errors when writing) to "file_list.txt".

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

GoodKarma

Quote from: Phil Harvey on November 15, 2022, 02:17:06 PMI have a few questions.

1. Do you want to process all files with the 2nd command but only JPG files with the first command?

2. Do you want to print the name if GPSImgDirection doesn't exist only after it has been copied from XMP:Yaw?

Assuming only JPG images for the 2nd command and you want to test GPSImgDirection after running the first command, then something like this may work:

exiftool -tagsfromfile %d%f.JPG '-GPS:GPSImgDirection<XMP:Yaw' -ext JPG 'E:\TEMP\phll_test\' '-GPS:GPSImgDirectionRef=Magnetic North' -if 'defined $GPS:GPSImgDirection or defined $XMP:Yaw' -efile5 file_list.txt

This will process only files which already have XMP:Yaw or GPS:GPSImgDirection, and will write the names of other JPG files (or files which had errors when writing) to "file_list.txt".

- Phil

Thank you for responding so swiftly Phil

1) No, I was just testing this again today and just tried using a small sample of JPG files, however, I later realised that I would need to perform this on DNG files as well.

2) I'd like to run the first command only on the files that do not have GPSImgDirection before copying anything from $XMP:yaw as All JPG & DNG files should already have XMP:Yaw.

However several hundred files(I believe only JPG and in many different folders) will also have GPSImagedirection tags from when I was previously working on this.

I guess I would need to run the second command first if that makes sense?


Phil Harvey

OK, I think this may do what you want:

exiftool -if 'not $gpsImgDirection' '-GPS:GPSImgDirection<XMP:Yaw' '-GPS:GPSImgDirectionRef<${XMP:Yaw;$_="Mag"}' -ext jpg -ext dng -v0 -r DIR

This command uses a few tricks:

1. The -v0 option will print the name of every processed file on lines starting with "========".  This will tell you all the files which don't have GPSImgDirection initially.

2. In order to avoid setting GPSImgDirectionRef in the case where XMP:Yaw doesn't exist, I'm using the advanced formatting feature to write "Mag" to GPSImgDirectionRef only if XMP:Yaw exists.

3. I'm using the -ext option to process only JPG and DNG files, and -r to recursively process subdirectories.

Note that processed files with neither GPSImgDirection nor XMP:Yaw will give "No writable tags set" warnings.

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

GoodKarma

Quote from: Phil Harvey on November 15, 2022, 04:02:46 PMOK, I think this may do what you want:

exiftool -if 'not $gpsImgDirection' '-GPS:GPSImgDirection<XMP:Yaw' '-GPS:GPSImgDirectionRef<${XMP:Yaw;$_="Mag"}' -ext jpg -ext dng -v0 -r DIR

This command uses a few tricks:

1. The -v0 option will print the name of every processed file on lines starting with "========".  This will tell you all the files which don't have GPSImgDirection initially.

2. In order to avoid setting GPSImgDirectionRef in the case where XMP:Yaw doesn't exist, I'm using the advanced formatting feature to write "Mag" to GPSImgDirectionRef only if XMP:Yaw exists.

3. I'm using the -ext option to process only JPG and DNG files, and -r to recursively process subdirectories.

Note that processed files with neither GPSImgDirection nor XMP:Yaw will give "No writable tags set" warnings.

- Phil

wow thanks, Phil, amazing stuff as always, out of curiosity what can ExifTool not do? There has been a solution to every problem I have had.

when it comes to chaining commands together, as I would like to expand on this command some more, I couldn't see much in the documentation except -argfile and -execute, are they the best option? I'd like to chain all the commands I use on my files and issue just a single ExifTool command, saving time and resources. At what point should I use execute or argfile? I use quite a lot of commands specifically on drone files


Phil Harvey

You should be using a -@ argfile if either the command line gets too long or if you can't perform the operation in a single command.

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