Beginner: write filename, lat, lon multiple jpgs; single *.csv

Started by zaction12, February 06, 2015, 12:44:15 PM

Previous topic - Next topic

zaction12

Hi,
I am completely new to command line run programs and scripting using batch files.  I am trying to use exiftools to read the filename, latitude, longitude, and altitude of every jpg file in a particular directory (and sub directories if possible).  I would like to export this data line for line in a single comma delimited format with a carriage return between each file's line of delimited data.

For example a folder containing:

SSP_7149.jpg
SSP_7150.jpg
SSP_7151.jpg
SSP_7152.jpg

script should output

out.csv or out.txt

"
SSP_7149.jpg, 29.05235678, 95.23444546, 300.4
SSP_7150.jpg, 29.05287598, 95.23244686, 284.2
SSP_7151.jpg, 29.05789878, 95.27315057, 302.5
SSP_7152.jpg, 29.05235245, 95.23487882, 315.3
"

I only have some limited skills in Python. Do I need to write a script that produces first a text file that lists all jpgs in a folder so that the batch file using exiftool can cycle through each file with a for loop or similar?  Does exiftool have this capability built in?  Any advice or code, or pseudocode would be greatly appreciated.  I'd like to access exiftools through a local batch file in the directory that will reference exiftools using the PATH environmental variable - this has already been set up.

Thank you very much,

ZAC

Phil Harvey

Hi Zac,

Try this command:

exiftool -csv -n -gpslatitude -gpslongitude -gpsaltitude -ext jpg -r DIR > out.csv

where DIR is the name of your directory.

- Phil

Edit:  Added -n
...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 ($).

zaction12

HI,
Amazing.  Thank you very much for the reply.  Works perfectly.  I've been sifting through the forums and help pages for couple days now and what I'm missing is the introduction to the structure of the exiftool command and list of commands/options.  Are the -GPSlongitude, -GPSLatitude, etc. considered shortcut tags? Is there any literature on the order of the options listed in the executed line? Any beginner help pages you can recommend? There are obviously many features that can be taken advantage of using exiftools.

Thanks very much for you help.  The table created with your program with the above script will be used to plot aerial photos in a GIS.  That spatial information will then be used to select certain photos based on a tiled project area. (~6000 photos).  Thanks again.
ZAC

Phil Harvey

Hi Zac,

The exiftool application documentation is obtained by running exiftool with no arguments.  It is also available as a web page or in PDF format.  This documention explains all ExifTool options, and the Tag Name documentation lists all pre-defined tags.

I have tried to start an ExifTool for dummies page, but never got very far.

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