Hi all,
Great tool!
I have several folders with images and I'm looking to automate the majority of my work. My end goal is to extract and data collect the locations/GPS coordinates of each and every image.
Can someone help with the methods and commands to pull the location data of each file and put them all in to a txt or csv file? If possible, adding a Google maps URL for each image would help even more, otherwise, the GPS coordinates in the format where I can enter it in to Google Maps to search for the location would be my end goal.
I searched the forum and did find an older thread with the following URL as the solution: exiftool -filename -gpslatitude -gpslongitude -T DIR > out.txt
I attempted it but it doesn't create the txt file with any of the data.
Any help would be appreciated. Thank you.
Quote from: dannyddn on December 27, 2018, 09:30:39 AM
I searched the forum and did find an older thread with the following URL as the solution: exiftool -filename -gpslatitude -gpslongitude -T DIR > out.txt
I attempted it but it doesn't create the txt file with any of the data.
That command will create a file named
out.txt. It may be an empty file (0 bytes) but it will create a file someplace. Normally, it will be in the current directory. You don't say what OS you're using, but if you're using windows and started a CMD window and didn't change the directory you're in, then that means the out.txt file will probably be in C:\Windows\System32, which isn't a good place for it. You might try to search for it by using
name:out.txt which would cause Windows search to look for only a file name, not search the file contents.
You can find details on creating a CVS file under the
-csv option (https://exiftool.org/exiftool_pod.html#csv-CSVFILE) docs and FAQ #12 (https://exiftool.org/faq.html#Q12). Basically, list the tags you want, add
-csv and redirect the output to a file. Your example command above would to do it, just replace the
-T with
-csv.
Creating a google link is a bit harder. You would probably have to create a text or csv file using the
-p (printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat). Something like
exiftool -p "$filename, $gpslatitude, $gpslongitude, http://www.google.com/maps/place/$gpslatitude,$gpslongitude" DIR >out.csv
Thanks a lot for the response!
Sorry, I'm using Win 10. I did a search initially for the txt file and couldn't find it, but I just did another and I ended up finding the file in C:/Users/ProfileName folder.
I tried the following command, it worked perfectly - exiftool -gpslatitude -gpslongitude -csv -r "DIR" > out.csv
I also tried your command, which also worked: exiftool -p "$filename, $gpslatitude, $gpslongitude, http://www.google.com/maps/place/$gpslatitude,$gpslongitude" DIR >out.csv
The only issue with both, is that it doesn't give the incorrect format for the coordinates, therefore I can't easily load it in Google Maps.
For eg, in the first command, I'm given the coordinates: GPSLatitude: 39 deg 54' 48.95" N, GPSLongitude:116 deg 23' 44.19" E.
For the second command, I'm given the following link which is broken: http://www.google.com/maps/place/39 deg 54' 48.95" N
I did some more research on the command, and for the above example image, the URL should be in the following format: http://www.google.com/maps/place/39.913597,116.395608
Is there a way to have ExifTool create the URL in this correct format which can be read by Google Maps?
Thanks!
Add -n to the command to write plain numerical coordinates. Or look at the -c documentation if you want to use any other arbitrary format.
- Phil
Thanks,
I gave that a try with the command which includes the Google URL: exiftool -p "$filename, $gpslatitude, $gpslongitude, http://www.google.com/maps/place/$gpslatitude,$gpslongitude" -n "DIR" >out.csv
The output it gives is: http://www.google.com/maps/place/39.9135972222222
It looks like it's adding the full Latitude but not the Longitude to the URL. Any adjustments to the command to include the comma and Longitude?
Oops, forgot the comma in the url would end up being separate. So it needs to be quoted.
Try
exiftool -p "$filename, $gpslatitude, $gpslongitude, """http://www.google.com/maps/place/$gpslatitude,$gpslongitude"""" -n
or
exiftool -p "$filename, $gpslatitude, $gpslongitude, \"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n
I gave those commands a try, it gave me the same result. I added the directory and output at the end of the commands though, is that incorrect?
For eg, I tried:
exiftool -p "$filename, $gpslatitude, $gpslongitude, """http://www.google.com/maps/place/$gpslatitude,$gpslongitude"""" -n "DIR" >out.csv
and
exiftool -p "$filename, $gpslatitude, $gpslongitude, \"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n "DIR" >out.csv
Can you copy/paste the output from a single file? I'm getting proper output here. Just leave of the >out.csv and copy/paste the result.
Here's what I get:
C:\>exiftool -p "$filename, $gpslatitude, $gpslongitude, \"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n y:\!temp\Test4.jpg
Test4.jpg, 5.346783, -3.985286, "http://www.google.com/maps/place/5.346783,-3.985286"
One more attempt, use %2C instead of the comma in the URL. That way you don't need quotes around the URL because the comma has been encoded.
exiftool -p "$filename, $gpslatitude, $gpslongitude, http://www.google.com/maps/place/$gpslatitude%2C$gpslongitude" -n "DIR" >out.csv
On, for instance, this page, http://f16.eu/2018/SouthAfrica.September/tn/x-s1_3656.jpg.index.html (http://f16.eu/2018/SouthAfrica.September/tn/x-s1_3656.jpg.index.html) I have a clickable location map link.
The url on the page is http://maps.google.co.uk/?q=-34.6710807419278 19.5080747741333 (A photograph by Alan Clifford: Whale at Pearly Beach)&z=13&t=h&output=original (http://maps.google.co.uk/?q=-34.6710807419278%2019.5080747741333%20(A%20photograph%20by%20Alan%20Clifford: %20Whale%20at%20Pearly%20Beach)&z=13&t=h&output=original)
Strangely, when you click on the link on my webpage, you get a satelite view but if you click on the link above or cut and paste the url into the browser, you get a map.
Google seems to do a redirection and the url ends up as https://www.google.co.uk/maps/place/34%C2%B040'15.9%22S+19%C2%B030'29.1%22E/@-34.6710807,19.5058861,744m/data=!3m2!1e3!4b1!4m5!3m4!1s0x0:0x0!8m2!3d-34.6710807!4d19.5080748 (https://www.google.co.uk/maps/place/34%C2%B040'15.9%22S+19%C2%B030'29.1%22E/@-34.6710807,19.5058861,744m/data=!3m2!1e3!4b1!4m5!3m4!1s0x0:0x0!8m2!3d-34.6710807!4d19.5080748)
When I right click on the web page and "copy link location", it turns into http://maps.google.co.uk/?q=-34.6710807419278%2019.5080747741333%20(A%20photograph%20by%20Alan%20Clifford:%20%20Whale%20at%20Pearly%20Beach)&z=13&t=h&output=original (http://maps.google.co.uk/?q=-34.6710807419278%2019.5080747741333%20(A%20photograph%20by%20Alan%20Clifford:%20%20Whale%20at%20Pearly%20Beach)&z=13&t=h&output=original) which gives me the satelite view.
When I created this coding originally, Google used to created pins tagged with a description, but that stopped working >:(
Quote from: StarGeek on December 29, 2018, 02:13:57 AM
Can you copy/paste the output from a single file? I'm getting proper output here. Just leave of the >out.csv and copy/paste the result.
Here's what I get:
C:\>exiftool -p "$filename, $gpslatitude, $gpslongitude, \"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n y:\!temp\Test4.jpg
Test4.jpg, 5.346783, -3.985286, "http://www.google.com/maps/place/5.346783,-3.985286"
One more attempt, use %2C instead of the comma in the URL. That way you don't need quotes around the URL because the comma has been encoded.
exiftool -p "$filename, $gpslatitude, $gpslongitude, http://www.google.com/maps/place/$gpslatitude%2C$gpslongitude" -n "DIR" >out.csv
Yes. It actually correctly builds the URL when you execute the command for a single file. The issue is when performing it on a folder and outputting it to a csv file.
File Only:
C:\Users\Home>exiftool -p "$filename, $gpslatitude, $gpslongitude, \"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n C:\Users\Home\Desktop\IMG_4024.jpg
IMG_4024.jpg, 43.6249694444444, -79.4850916666667, "http://www.google.com/maps/place/43.6249694444444,-79.4850916666667"
Folder
C:\Users\Home>exiftool -p "$filename, $gpslatitude, $gpslongitude, \"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n C:\Users\Home\Desktop\IMG_4024.jpg >out.csv
D Column: "http://www.google.com/maps/place/43.6249694444444
E Column: -79.4850916666667"
Based on the above, the comma is missed and the value of the longitude is being shifted over to the next column in excel.
Quote from: dannyddn on December 30, 2018, 09:39:24 AMBased on the above, the comma is missed and the value of the longitude is being shifted over to the next column in excel.
A vital piece of info you left out. It's not a case of exiftool leaving out the longitude, as you said, but of excel improperly splitting an encapsulated cell value.
For the record, LibreOffice properly loads the URL column.
Searching around, it appears that Excel has a problem with the space after the comma. See this SuperUser answer (https://superuser.com/a/927374/314998). Change the line so that the commas don't have a space after them.
Great, that clue helped me resolve the issue.
In my case though, it wasn't the space between the columns, it was a space before the URL (beforethe backslash).
exiftool -p "$filename, $gpslatitude, $gpslongitude,\"http://www.google.com/maps/place/$gpslatitude,$gpslongitude\"" -n "DIR" >out.csv
Appreciate the help, great support forum!