Add GPS Tag too latest .jpg and then remove GPS tag from all other .jpgs

Started by kiteboy, March 23, 2017, 07:58:47 AM

Previous topic - Next topic

kiteboy

Hi guys

I am lost in trying to solve this issue

What Im trying to acheive is to just GPS tag the latest jpg in a directory.

Once that is done I want to remove any other GPS tags from any other images including the previously tagged jpg which has now been superceeded by a newer jpg

Im trying to create a script to do this automatically and any advice or pointers would be great as Im completely stuck at the moment

I know the command to tag but no idea how to go about doing the above

The file are in the format of 20170315 130103.jpg for example

Thanks again


Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kiteboy


Phil Harvey

I think this script will do it:  The script takes a directory name as an argument, and clears the GPS from all files except the last one, for which it sets the GPS (since you named them by date this should be the most recent one):

#!/bin/sh
files=($*/*)
exiftool <arguments to set GPS> ${files[@]:(-1)}
unset 'files[${#files[@]}-1]'
exiftool -gps:all= ${files[@]}


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kiteboy

Thanks for taking the time to reply Phil - Really apppreciated

Still cant get it quite right

At the moment I have

#!/bin/sh
files=($*/*)
exiftool /home/www/myweb.co.uk/cameras/myweb/South/Me\ /IP\ /Camera/Me\ /House ${files[@]:(-1)}
unset 'files[${#files[@]}-1]'
exiftool -gps:all= ${files[@]



Im getting the folliwng error
Syntax error: "(" unexpected

Tried various iterations but not sure where Im going wrong yet

Again - many thanks Im a complete newbie here

Phil Harvey

I don't know what you are doing with your first ExifTool command (you are meant to add your gps here). also, you are missing the trailing "}" on the last line.

You should execute this script with a directory name.   ie)

myscript /home/www/myweb.co.uk/cameras/myweb/South/Me\ /IP\ /Camera/Me\ /House

note that the script must be executable to run it like this, so you should "chmod 755 myscript" to be able to run it.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

It seems that your "sh" shell is different than mine somehow.  I have never used this syntax myself -- I got this from googling, but it worked for me when I tried on OS X.  I don't have time to test this on other systems right now, but I will when I get a chance.  Until then you may be able to solve your problem by some googling of your own.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

kiteboy

Think I may have it - just looking now - I have changed some jpgs anyway

So just looking to see if its working as expected

Thanks m8

Hayo Baan

Instead of /bin/sh use /bin/bash in your script header. That will likely solve the issue; sh on Mac is different form the unix ones.
Hayo Baan – Photography
Web: www.hayobaan.nl

kiteboy

Yep that was part of it - also something to do with the spaces in the file path - not figured that out yet but its running at least