I want to geotag some of my photos. I am usins gpsbabel to convert the log file to a gpx file. ← this works fine with a shell script.
The converted file should be loaded into gpsphotolinker (this app does not support AS or Shellscripts so the only way is GUI scripting)
I am able to load the app, call the dialogue (the one that should load the converted gpx file) BUT then i am stuck. I am not able to select the file automaticlly…
after lloading the gpx file I want to call the “load photos” button. ← this works fine with GUI
a specified folder, containing the photos should be selected and loaded. BUT again. I am stuck at this selection part.
above you will find my code and also some pictures of the gui if it is helpful. THX for all tipps and tricks to get this working
every body who is interested here is the code that works for me
please see below...
selecting datafile, convert data file to gpx file, open gpsphotolinker, switch to batch mode, select gpx file, select photo folder, click process batch tagging(need to be done manually)
there is a new version of my script. But I think there is still work to improve the script. Please Feel free to adapt and optimize the script so that it can be used on any macihen and not only mine (according to the hardcoded folders and so on). BTW:
I DID NOT WRITE GPSBABEL OR GPSPHOTOLINKER I ONLY USE IT AND I DO NOT CLAIM ANY RIGHTS ON IT OR THE SCRIPT. IT IS JUST AN AUTOMATED WORKFLOW TO MAKE MY LIFE A LITTLE EASIER
maybe an option to implement is ask to read several log files… so that the “convert” is running as log as there are files to convert. GPSPhotoLinker also has to import these files first before loading the pictures.
Lets see If someboy has a clue. I am just a basic-non-pro-2cents-when-ever-I-have-time-wannabe coder…
How can i select multiple LOG files and let these processed by the convert-part? and after that, how can i rename the output of the convert-part (eg. and sequenced number ad the end?)??
set logFolder to choose folder with prompt "Bitte wähle einen Ordner mit LOG Dateien aus"
set photofolder to choose folder with prompt "Bitte wähle das Verzeichnis mit den zu taggenden Fotos aus"
set output_folder to (path to documents folder as text) & "gps_backup_files:"
set filename to do shell script "/bin/date +%Y%m%d" & "track_log.gpx"
set gpxfile to POSIX path of output_folder & filename
tell application "Finder" to set logFiles to files of logFolder -- whose name extension is ".log"
repeat with oneFile in logFiles
convert(oneFile as alias, gpxfile)
-- delay 5
geotag(gpxfile, photofolder)
end repeat
the date_format() handler is not needed any more.
you can use the commented out whose name extension. if you want to filter the log files.
The delay is actually not needed, too. If the script passes this line, all further actions are already done.
thx very much for all your help Stefan & Craig. Now it works just like I want it and it saves me a lot of time to geotag my photos
here is the final script (but I think there is still sth. to improve,shorten, etc):
set logFolder to choose folder with prompt "Bitte wähle einen Ordner mit LOG Dateien aus"
set logFolderOut to (path to documents folder as text) & "gps_backup_files:"
set logfolder2 to "leopard:users:goeste:documents:gps_backup_files:"
set picFolder to choose folder with prompt "Bitte wähle die zu taggenden Fotos aus"
set gpxDate to do shell script "/bin/date +%Y%m%d" --datum erzeugen
on convert(input, output) --log zu gpx konvertierung
set program_path to path to me --pfad zu gpsbabel
tell application "Finder" to set forig to name of input --altendateinamen merken
set fDate to do shell script "/bin/date +%Y%m%d" & "-" --datumsdatei erzeugen
set fname to output & fDate & forig --dateinamen setzen
set gpxfile to text 1 thru -5 of fname --dateiendung entfernen
do shell script POSIX path of program_path & "Contents/Resources/gpsbabel -t -i NMEA -f " & POSIX path of input & " -o GPX -F " & POSIX path of gpxfile --konvertierung mit gpsbabel
do shell script "mv " & POSIX path of gpxfile & " " & POSIX path of gpxfile & ".gpx" --dateiendung gpx setzen
end convert
on geotag(gpx)
activate application "GPSPhotoLinker"
tell application "System Events"
tell process "GPSPhotoLinker"
click radio button 3 of tab group 1 of window "GPSPhotoLinker" --batch-modus aktivieren
delay 1
click menu item "Load Tracks From File." of menu 1 of menu bar item "Tracks" of menu bar 1 --load tracks klicken im menü
delay 0.5
keystroke "/" using {control down} --gehe zu.. öffnen
tell window 1
tell sheet 1
set value of text field 1 to gpx --log file angeben als unix pfad
click button 1
end tell
click button 1
end tell
delay 0.5
click button 4 of window 1
delay 3
--hier könne es weiter gehen mit der Automatisierung...
end tell
end tell
end geotag
on loadphotos(pfolder)
activate application "GPSPhotoLinker"
tell application "System Events"
tell process "GPSPhotoLinker"
click menu item "Load Photos." of menu 1 of menu bar item "Photos" of menu bar 1 --load photos klicken
delay 0.5
keystroke "/" using {control down} --gehe zu.. öffnen
--lade Bilderverzeichnis
tell window 1
tell sheet 1
tell sheet 1
set value of text field 1 to POSIX path of pfolder --bilder folder angeben als unix pfad
click button 1
end tell
click button 1
end tell
end tell
end tell
end tell
end loadphotos
--hier gehen die abläufe los
tell application "Finder" to set logFiles to files of logFolder whose name contains ".log" --lesen aller .log files
repeat with onefile in logFiles
convert(onefile as alias, logFolderOut) --konvertieren und bennen der logfiles
end repeat
tell application "Finder" to set gpxFiles to files of folder logfolder2 whose name contains gpxDate and name contains ".gpx" --lesen aller .gpx files mit aktuellem datum (verhinter doppel import)
repeat with gpxfile in gpxFiles
geotag(gpxfile as alias) --einlesen der .gpx files
end repeat
loadphotos(picFolder) --einlesen des bilder verzeichnises
thx again and keep up your work… I’ve learned a lot during this few days
¢ logFolder and logFolderOut point to the same path. Certainly only one of them is necessary.
¢ It’s strongly recommended to escape POSIX path always with quoted form of, because the path could contain space characters, which are recognized as parameter delimiters by the shell
for example
do shell script quoted form of (POSIX path of program_path & "Contents/Resources/gpsbabel") & " -t -i NMEA -f " & quoted form of POSIX path of input & " -o GPX -F " & quoted form of POSIX path of gpxfile --konvertierung mit gpsbabel
do shell script "mv " & quoted form of POSIX path of gpxfile & " " & quoted form of (POSIX path of gpxfile & ".gpx") --dateiendung gpx setzen
Consider that after quoted form of the whole path including all concatenations must be within parentheses
Thx Stefan, I ran into this trouble right now, after renaming the .app (name with spaces).
I also built in a create_folder if the outputfolder for the gpx files does not exist.
Thx again