1

I have a rather clumsy and inefficient way to do this with exiftool, find, etc., but maybe there's a better way …

I have more than 24 thousand images, from several different devices.  I'd like to make lists of those that have GPS tags and those that don't.  Or one list with each identified as having or not.  And either at the same time or in a separate job, to reverse geocode a description of the location in an exif comment for those that have GPS.

Apple's Photos app sorts them by location but it keeps that info separate from the photo.  (And it currently crashes my laptop when I try to open the app)

LibreOffice Calc can handle more than 24K rows but I've seen its performance go to crap with large amounts of data. same for TextEdit. So I'll likely run the thing non-recursive in each directory. My "clumsy method" would take advantage of the fact that exiftool will leave the GPSDateTime field blank when no GPS data. I didn't know about the -if option—I'll have to look into that.

It was clumsy because I thought I would have to run each file to a temp file of tags, check for GPS in the temp file, and then do something with the image file based on that. So that is alleviated by the ability to put multiple files in one CSV list. But then I have further actions to take with the list, and that's daunting with more than three thousand directories.

5
  • Do you have space, ,,tab,newline character in your filenames? Do you have only JPG,PNG,TIFF or you have also RAW files. Do you use for RAW files XMP side file? Aug 21 at 6:38
  • There are a few raw files, but I don't know how I got them or anything about them. I'll probably convert them to .jpg before continuing this project. Most of the files are .jpg taken by iPhone, iPad, Microsoft Surface, and various digital cameras.
    – WGroleau
    Aug 21 at 19:04
  • Do you have any symbols like space, ,, ; in the filenames? Aug 21 at 19:06
  • Also do you have diversity in extensions like JPG, JPEG, Jpg, etc? Aug 21 at 19:09
  • 1
    Some of the directory names have spaces, generated by an export from Photos.app. There are >95% .jpg, .JPG, .jpeg. but some .gif and .png
    – WGroleau
    Aug 21 at 19:14

4 Answers 4

0

There are scripts in various languages, such as Python, or Windows PowerShell to extract latitude and longitude EXIF data. Sort output on value, so null will be grouped together.

0

Jhead is a command line program reads & alters EXIF data. Jhead is available for Windows and Linux. A batch file can extract GPS information.

A simple example of a Windows batch script using grep (Unix utility ported to Windows):

@echo off
for %%x in ("*.jpg") do (
echo %%x
jhead %%x | grep "GPS L"
echo, )

Sample output from the script:

IMG01.jpg

IMG02.jpg
GPS Latitude : N 40d  8m 33.70s
GPS Longitude: W 117d 52m 10.59s
 

In the example, IMG01 doesn't have any GPS tags, IMG02 has a GPS tag.

Google's Geocoding API looks like it can give you location information based on Lat/Long (You'll need to explore this).

0
0

Using exiftool, to get a simple list of all files that include a GPS coordinate, you could do this
exiftool -if "$GPSLatitude" -p "$FilePath" /path/to/files/

To get a Y/N in front is a bit more complex, because by default, exiftool won't print anything for missing tags. To work around this, the -f (-ForcePrint) option is used with -api MissingTagValue option to set the default to 'N'. Exiftool's Advanced formatting feature is used to print a 'Y' if the tag exists. The -srcfile option is used to read and prioritize XMP sidecars if they exist. The -ext (-extension) option is used to exclude XMP files, as it can be assumed they are sidecars
exiftool -srcfile %d%f.xmp -srcfile @ --ext XMP -f -api "MissingTagValue=N" -p "${GPSLatitude;$_='Y'} $FilePath" /path/to/files/

You might also look at exiftool's -csv option and get CSV file which you could then load into Excel/LibreOffice and see all the values directly. Also included is the -n (--printConv) option to output in decimal format rather than Degrees/Minutes/Seconds
exiftool -csv -n -GPSLatitude -GPSLongitude /path/to/files/ >out.csv

Replace /path/to/files/ with the actual path to the files you want to process. Add -r to recurse into subdirectories. If this command is run under Unix/Mac/Powershell, reverse any double/single quotes to avoid variable interpretation.

10
  • What about RAW with GPS info in XMP? Aug 21 at 15:42
  • Also you will print files which are not images Aug 21 at 15:45
  • All of these commands will read either EXIF or XMP data if it's embedded in the file, as it will output exiftool's Composite GPS tags. If there are XMP sidecars, it will read those and output the results from that file. The only problem would be dealing with a Y for the XMP files and a N for the matching RAW files. You might use the [url=exiftool.org/… ([tt]-extension[/tt]) option[/url] to ignore the RAW files e.g. --ext CR2. That would output only the matching xmp.
    – StarGeek
    Aug 21 at 15:48
  • How many extensions of RAW files you should ignore? And the OP will see in list file with XMP extension, not image file. Aug 21 at 15:50
  • It will list all files that exiftool can read. This would included filetypes other than images that will not have GPS coordinates, such as .docx or .txt. The [url=exiftool.org/… ([tt]-extension[/tt]) option[/url] can be used to limit or exclude unwanted filetypes.
    – StarGeek
    Aug 21 at 15:50
0

What I did was simpler than what I first had in mind, but still not ideal:

find Sort_By_Date -type d -print | while read DIR; do                                                           
  exiftool -csv -FileName -GPSDateTime -GPSPosition -GPSAltitude "$DIR" > "$DIR/exif-list.csv"
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.