Inverse Geotagging without using Redirection

Started by dzeek, February 27, 2021, 03:19:31 PM

Previous topic - Next topic

dzeek

Is there some way to tell ExifTool to send the output to a file without using redirection?

In other words send the output to a file without using the ">" operator in the following example:

exiftool -p gpx.fmt *.jpg > out.gpx


I have a Windows 10 program that runs ExifTool in a shelled subprocess environment where redirection can't be used.

Thank you

StarGeek

I haven't tried it but maybe take a look at note #2 under the -w (-TextOut) option.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

dzeek

Thank you for the suggestion. I saw that option before but didn't immediately see an easy way to use it to generate a GPX. I'll look at it again.

dzeek

FYI. I got this command to work using -W.


exiftool -p gpxH.fmt *-00001.jpg -W+! out.gpx -execute -p gpxB.fmt *.jpg -W+ out.gpx -execute -p gpxT.fmt *-00001.jpg -W+ out.gpx


where:

gpxH.fmt is:

#------------------------------------------------------------------------------
# File:         gpx.fmt
#
# Description:  Example ExifTool print format file to generate a GPX track log
#
# Usage:        exiftool -p gpx.fmt -ee FILE [...] > out.gpx
#
# Requires:     ExifTool version 10.49 or later
#
# Revisions:    2010/02/05 - P. Harvey created
#               2018/01/04 - PH Added IF to be sure position exists
#               2018/01/06 - PH Use DateFmt function instead of -d option
#               2019/10/24 - PH Preserve sub-seconds in GPSDateTime value
#
# Notes:     1) Input file(s) must contain GPSLatitude and GPSLongitude.
#            2) The -ee option is to extract the full track from video files.
#            3) The -fileOrder option may be used to control the order of the
#               generated track points when processing multiple files.
#------------------------------------------------------------------------------
#[HEAD]<?xml version="1.0" encoding="utf-8"?>
#[HEAD]<gpx version="1.0"
#[HEAD] creator="ExifTool $ExifToolVersion"
#[HEAD] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
#[HEAD] xmlns="http://www.topografix.com/GPX/1/0"
#[HEAD] xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
#[HEAD]<trk>
#[HEAD]<number>1</number>
#[HEAD]<trkseg>


gpxB.fmt is:

#[IF]  $gpslatitude $gpslongitude
#[BODY]<trkpt lat="$gpslatitude#" lon="$gpslongitude#">
#[BODY]  <ele>$gpsaltitude#</ele>
#[BODY]  <time>${gpsdatetime#;my ($ss)=/\.\d+/g;DateFmt("%Y-%m-%dT%H:%M:%SZ");s/Z/${ss}Z/ if $ss}</time>
#[BODY]</trkpt>


gpxT.fmt is:

#[TAIL]</trkseg>
#[TAIL]</trk>
#[TAIL]</gpx>


ne17

#4
I found when I used that command string in exiftoolgui ETdirect I ended up with mutiple xml headers.  After searching through exiftool application documentation I spotted End()  - so I've ended up with this version (copied from the ET direct command box) which will overwrite out.gpx if it exists in the folder or create it if not.  I've given my full path to the gpxH.fmt etc. files so I can run this in many several image folders to output a single .gpx file of the gps coordinates in all jpgs in each folder (some don't have altitudes so the -m is needed).

-if End() -p "c:\exiftoolgui\gpxH.fmt" . -W+! out.gpx -execute -m -if $gpsdatetime -fileorder gpsdatetime -p "c:\exiftoolgui\gpxB.fmt" -ext jpg  -W+ out.gpx -execute -if End() -p "c:\exiftoolgui\gpxT.fmt" -W+ out.gpx

(Phil's simpler command strings https://exiftool.org/geotag.html#GPX works if I run exiftool in a command window, but on windows I find exiftoolgui slightly easier to use navigating between folders)