How not to set "empty" tags from XML

Started by yarda, February 29, 2016, 05:30:42 AM

Previous topic - Next topic

yarda

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.

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yarda

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...

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

yarda

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.