Aloha,
I am looking for a command line that does the following:
Extracts only the GPS lat/long information from all photos in a directory and puts them all in one text file.
Essentially, the txt will have three columns: The first is the photo name and the second and third will be the lat long.
Can this be done? I have tried some combinations but failed. Now I am totally confused.
Thanks in advance for the help!
Chui
Hi Chui,
Try this command:
exiftool -filename -gpslatitude -gpslongitude -T DIR > out.txt
where DIR is the name of a directory containing the images (like c:\pictures for example). Put quotes around the directory name if it contains spaces.
This command will create a tab-delimited file called "out.txt" with your specified columns.
- Phil
Wow! Thanks Phil! It worked perfect!
Is there a way to change those output lat/long into decimal degrees? And if so, will the conversion cause a loss of precision in the coordinates?
Chui
Hi Chui,
Add the -n option to the command to output the coordinates as signed decimal degrees. In fact, you may gain precision by doing this because the -n value is returned at the full precision available.
- Phil
Thanks Phil for all your help. I know you hear this often but Exiftool is awesome! ;D
Hi Chui,
Quote from: angelpoo on January 21, 2011, 12:50:21 PM
I know you hear this often but Exiftool is awesome! ;D
I may have heard it before, but I don't often acknowledge because I'm not very good at accepting praise. However, it is appreciated. Thanks. :)
This also worked great for me! Thanks Phil.
I do have an additional question:
I have a directory/folder that contains a whole bunch of other directories/folders with geotagged photos in them. I'm looking for a quick way, batch style, to have exiftool look through all of the folders and all of the photos within, extract coordinates, and put them in the text file. Is this possible? Could it also label the photos based on which folder they came out of?
Thanks in advance.
Sure. The -r option recurses into sub-directories, and just add -directory to output the directory name:
exiftool -filename -directory -gpslatitude -gpslongitude -T -r DIR > out.txt
Or, you could use the new -csv option, which automatically writes out a "SourceFile" column which is the full path name of the file:
exiftool -gpslatitude -gpslongitude -csv -r DIR > out.csv
- Phil
Wow! Always such fast and clear responses. Thanks so much.
Hi Phil,
I'm having troubles with the command to extract the GPS data. It doesn't write the .txt file. Any ideas?
What system are you running on, and what is the exact command you used?
If you used the command in my first post of this thread, it will have created an "out.txt" file in the current directory from where you ran exiftool.
- Phil
Thank you both for your responses. Yes it's there alright...up a couple of directories. I kept expecting to see it in the same directory as the photos (my programmer Neighbour helped me straight away). Apologies if I wasted your time. I can see I'm going to be having fun with ExifTool...I've been able to create a photo (Google) map of over 100 images of road defects (on proof sheets). I've got 1000's more to do - so your tool is awesome for the job [just importing a photo library into Google Maps muddled up the sequence for some reason]. I just donated $10AUD. Much obliged, Ben. :)
Hi Ben,
Glad you got it working.
Thanks for the donation!
- Phil
This thread gave me a quick solution to what I wanted to do in particular and gave me a toehold into understanding/using the power of ExifTool.
Thank you Phil Harvey.
Quote from: BenjaminTheThird on March 02, 2017, 10:29:04 PM
Hi Phil,
I'm having troubles with the command to extract the GPS data. It doesn't write the .txt file. Any ideas?
Hi all.
Im having the same issue. When i try:
exiftool -filename -directory -gpslatitude -gpslongitude -T -r DIR > out.txt
my txt is created, but its blank, despite i see a command line being create with all data that i wish (and closes after).
Im using windows 7.
Thanks for help.
If you are typing this command in a cmd.exe window then I don't see why it shouldn't work.
- Phil
Quote from: Phil Harvey on April 10, 2017, 10:39:22 AM
If you are typing this command in a cmd.exe window then I don't see why it shouldn't work.
- Phil
Its on a cmd.exe window.
when i try simple "echo" command on a string to write on a txt, its works.
but exiftool data its not recorded on a txt when a use code above.
I don't understand it, but you can work around the problem by having ExifTool write the output text file with this command:
exiftool -filename -directory -gpslatitude -gpslongitude -T -r -W+! out.txt DIR
- Phil
Still not working with this code.
When i run exiftool, a new cmd window is opened?
Maybe its the problem...
The steps are:
1. Run "cmd.exe"
2. Type your exiftool command in the cmd.exe window
If you do this, then a new cmd window should not open. (or at least I don't understand why it would. If it does, then something funny is going on)
- Phil
Im doind exactly it, Phil.
And its opening a new cmd window. When this new cmd windows finishes, it closes fast and return to old cmd window (i can see command, but no results).
My exiftool.exe is in C:Windows folder
Trying to search now how to not open a new cmd window.
thanks anyway
problem solved.
i reduced windows defender level privileges and it worked.
thanks
Wow. I would not have guessed that Windows Defender would cause another cmd.exe window to open. That's just crazy.
Hi Phil,
I followed your posts, thank you for all your help! I tried to export long/lat coordinates in decimal and the time from a bunch of geotagged images and am running into problems.
I am working on a Mac. Here is the code I am using:
exiftool -filename -gpslatitude -gpslongitude -time -T –n DIR > out.csv
I am receiving an error..."n" is not found and is "time" not found.
Any Advice? I tried it yesterday with the simple code [without n and time] and it worked.
Best, Mona
Hi Mona,
What time are you trying to export? GPSTimeStamp (and maybe GPSDateStamp too?) I assume. And your -n problem is because the dash is not a minus character, but instead is some sort of unicode dash.
Try this:
exiftool -filename -gpslatitude -gpslongitude -gpstimestamp -gpsdatestamp -n DIR > out.csv
- Phil
Hii Phil,
I want to ask, how to insert long,lat,alt, to images using exiftool?
i have problem to insert coordinate to my images?
Thank you,
Rizki
Under Windows, it's easier to write GPS coordinates if you have them in decimal format e.g. 40.6892, -74.0445. Additionally, there is a reference tag for each value of Altitude, Latitude, and Longitude to account for whether the value is above/below sea level, North/South, or East/West. So in the case of the above value, you could write:
exiftool -GPSLatitude=40.6892 -GPSLatitudeRef=N -GPSLongitude=-74.0445 -GPSLongitudeRef=W -GPSAltitude=10 -GPSAltitudeRef=Above
Exiftool is smart enough that you can just assign the GPS value to the associated reference tag and it will figure out the correct value (though you'll need a +/- for the GPSAltitudeRef):
exiftool -GPSLatitude=40.6892 -GPSLatitudeRef=40.6892 -GPSLongitude=-74.0445 -GPSLongitudeRef=74.0445 -GPSAltitude=10 -GPSAltitudeRef=+10
See GPS Tags (http://www.exiftool.org/TagNames/GPS.html) for some further information.
Quote from: StarGeek on July 12, 2017, 02:02:40 PMUnder Windows, it's easier to write GPS coordinates if you have them in decimal format
Replying to myself. The problem I always had was trying to escape the double quotes for the seconds with DMS coordinates. After re-reading the link I provided, I finally noticed that exiftool doesn't need those extra bits. It will happily accept the DMS without them. So
-GPSLatitude="40 41 21.2892 N" -GPSLatitudeRef="40 41 21.2892 N" works perfectly well. Today I learned.
Thank you Star,
How about to inject coordinate using .csv file? i have problem when i do that.
Thank you for advice,
Rizki,
Each line of your CSV is enclosed in quotes. That means each line is a single cell. Remove the leading and trailing quote and it should work.
Hello everyone,
I was using the command [exiftool -filename -gpslatitude -gpslongitude -T U1 > out.txt]. When I open the out.txt file I get the names of the image and - - (two dashes). Does that me the images doesn't content GPS fields? I also would like to know which time is the image created time among (Modification, Access, Inode Date/TIme)?
Yes, a dash means the given tag wasn't extracted from the file.
Add -createdate to your command to extract the creation time if it exists in the metadata.
As for filesystem creation date: If you are on Unix the file creation date isn't stored in the filesystem. On Mac, this can be accessed through the MDItemFSCreationDate tag.
- Phil