List all filenames of images containing GPS or serial number data

Started by catharsis, June 26, 2021, 10:54:45 PM

Previous topic - Next topic

catharsis

I've been doing like this to alert me if any images contain GPS or serial number data (filtering out false positives "Gpsdop"):

exiftool -r . | egrep -i '(GPS|serial)' | grep -v 'Gpsdop' | sort | uniq -c | sort

The problem is that if I do get a hit, I have no idea what file matched, so I have to do like "exiftool -r . > temp.txt", open the temp.txt in a text editor, search for whatever was found with the initial command, and then scroll up to find the filename, then repeat for the next match and all following matches, then delete the temp.txt.... this can potentially take hours

Surely there's a better way?

Whatever command is used should produce NO output if no files contain matching data.


StarGeek

Use the -if option.

The serial number tag may differ depending upon the camera, but the NEFs and CR2s I have both use SerialNumber.

Try something like this
exiftool -r -if "$GPSLatitude or $SerialNumber" -GPS* -SerialNumber .
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

catharsis

I had to use single quotes instead of double quotes to get it to work, but it did work, although I really only want one line per matching file, and I really only care about the filenames.  I switched to using the -filename option which brought it down to just two lines per file then I used some grep and cut commands to truly get it down to just the filename

Here's what I ended up with:

exiftool -r -if '$GPSLatitude or $GPSLongitude or $GPSPosition or $SerialNumber or $LensSerialNumber or $CameraSerialNumber' -filename  . | grep 'File Name' | cut -c 35-

StarGeek

Quote from: catharsis on June 27, 2021, 09:53:25 AM
I had to use single quotes instead of double quotes to get it to work,

Ooops.  When I started typing that answer, I told myself to use single quotes because it's obviously a bash shell type user, because Windows users don't know grep.  And promptly forgot about it.

You can use a tag name that doesn't exist to get a list of just the file paths, though you would have to pass it through sed or something to get rid of the leading equal signs.  Here I use the non-existent tag named "aaa".
C:\Programs\My_Stuff>exiftool -g1 -a -s -if "$filename=~/^test/" -aaa y:\!temp\
======== y:/!temp/test.pdf
======== y:/!temp/test_drive.jpg
======== y:/!temp/test_drive.MP4
======== y:/!temp/test3 (2).jpg
======== y:/!temp/test.mp3
======== y:/!temp/test2.mp3
======== y:/!temp/test_1.jpg
    1 directories scanned
  121 files failed condition
    7 image files read
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).