ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: yarda on February 29, 2016, 05:30:42 AM

Title: How not to set "empty" tags from XML
Post by: yarda on February 29, 2016, 05:30:42 AM
Could you help one more time, pls...

Imagine the following XML snippet

<rdf:RDF>
<rdf:Description>
<FileName>image.jpg</FileName>
<Description></Description>
<GPS:GPSLatitude></GPS:GPSLatitude>
<GPS:GPSLongitude></GPS:GPSLongitude>
<GPS:GPSAltitude></GPS:GPSAltitude>
</rdf:Description>
</rdf:RDF>

If I use this with the command: exiftool -q -overwrite_original -all= -author 'Yarda' -tagsfromfile %f.xml I will end up with empty DESCRIPTION which is not nice but bearable; however, my GPS will be set to 0,0,0

GPS Position                    : 0 deg 0' 0.00", 0 deg 0' 0.00"

which is bad...

How to use/filter only what has some meaningful content? I tried to us -if but that is for a different usage. Some filter? -api

Thank you for comments.

Yarda.
Title: Re: How not to set "empty" tags from XML
Post by: Phil Harvey on February 29, 2016, 07:14:16 AM
Hi Yarda,

This may affect other tags, but for the example you gave adding -n to the command will prevent ExifTool from trying to convert the Lat/Long values to something meaningful.  However, then the GPS coordinates must be in degrees only if they exist.

- Phil
Title: Re: How not to set "empty" tags from XML
Post by: yarda on February 29, 2016, 07:41:26 AM
In my case I have this format, so that the -n is not what I can use...

<GPS:GPSLatitude>22.0355822000000003413333616 N</GPS:GPSLatitude>
<GPS:GPSLongitude>11.1165017999999999886995283 E</GPS:GPSLongitude>

So, need to do some filtering of "unwanted/empty" tags outside of exiftool then...
Title: Re: How not to set "empty" tags from XML
Post by: Phil Harvey on February 29, 2016, 07:45:18 AM
Quote from: yarda on February 29, 2016, 07:41:26 AM
So, need to do some filtering of "unwanted/empty" tags outside of exiftool then...

Did I say that?  I can think of at least three other ways to do this with ExifTool.  I just tried the easiest one first, given the situation you presented.

Try adding this to your command instead:  -api 'filter=$_ = undef unless length'

- Phil
Title: Re: How not to set "empty" tags from XML
Post by: yarda on February 29, 2016, 07:54:28 AM
No, you did not say that! I was wrongly reading in between your lines... :-D

The suggested filter of yours works like a charm.

Thank you.