How to remove address IPTC values from keywords via command line?

Started by beernoo, January 23, 2020, 03:04:25 PM

Previous topic - Next topic

beernoo

Hi there and thanks for the very insightful forum!

I am using Geosetter to reverse geo lookup EXIF GPS data and auto populate IPTC address fields (based on the geonames.org API).
That works great but Geosetter also extra populates Keywords with all retrieved address elements which is not a desired side effect in my case.
E.g. the below gets copied both in respective IPTC fields and concatenated with pre-existing keywords.
City                            : Wien, Innere Stadt
Sub-location                    : Innere Stadt
Province-State                  : Wien
Country-Primary Location Code   : AUT
Country-Primary Location Name   : Austria


I would like the remove the above IPTC address values from the Keywords while keeping any pre-existing Keywords.

I tried the below (inspired by https://exiftool.org/forum/index.php?topic=6463.0) with no effect:


A) Add two IPTC Keywords in Irfanview
Vacation
Sun

B) Edit the Image in Geosetter: Edit Data > Location > Get From Web

C) Check IPTC Keywords in Irfanview (looks like Geosetter appended all address fields populated from geonames API except for sub-location)
Vacation
Sun
Austria
AUT
Wien
Wien, Innere Stadt

D)
Run Command:
.\exiftool -keywords-<City -keywords-<Sub-location -keywords-<Province-State -keywords-<Country-PrimaryLocationCode -keywords-<Country-PrimaryLocationName "P:\Path\IMG_9731.JPG"
or
.\exiftool "-keywords-<City" "-keywords-<Sub-location" "-keywords-<Province-State" "-keywords-<Country-PrimaryLocationCode" "-keywords-<Country-PrimaryLocationName" "P:\Path\IMG_9731.JPG"

Result:
    1 image files updated

E. Check again in Irfanview
Vacation
Sun
AUT (Country-Primary Location Code)
Wien (Province-State)
Wien, Innere Stadt (City)

Issue: only Austria (Country-Primary Location Name) got removed


Can you please advise?
Thank you!

StarGeek

First, clarification is needed.  Are the keywords filled with
Vacation
Sun
Austria
AUT
Wien
Wien, Innere Stadt

or is it
Vacation
Sun
AUT (Country-Primary Location Code)
Wien (Province-State)
Wien, Innere Stadt (City)


Because you second listing has data that is unlikely to be removed with the commands you're trying.

Quote from: beernoo on January 23, 2020, 03:04:25 PM
I would like the remove the above IPTC address values from the Keywords while keeping any pre-existing Keywords.

See FAQ #17, the part with the bold face copying multiple tags to a single list .  Your second command is almost correct, (quotes are needed around argument that has a greater/less than symbol) but doesn't take into account the fact that the later commands overrule the previous ones.  That's why only Country-PrimaryLocationName was removed.  It overrode all the previous ones.

So what you want to do, as mentioned in the above FAQ, is use this command:
.\exiftool -AddTagsFromFile @ "-keywords-<City" "-keywords-<Sub-location" "-keywords-<Province-State" "-keywords-<Country-PrimaryLocationCode" "-keywords-<Country-PrimaryLocationName" "P:\Path\IMG_9731.JPG"

Additionally, because Geosetter is much better with metadata then irfanview is, you should check the XMP:Subject keywords tag.  Anything that Geosetter is writing into IPTC:Keywords, it is also writing to XMP:Subject.  And because irfanview doesn't have XMP support (even though it was requested nearly 10 years ago), you won't see that data.

QuoteThat works great but Geosetter also extra populates Keywords with all retrieved address elements which is not a desired side effect in my case.
E.g. the below gets copied both in respective IPTC fields and concatenated with pre-existing keywords.

To avoid this, look at this section of Geosetter's Settings
"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

beernoo

@StarGeek: Thank you so much for your answer. The command line worked and the root cause was the GeoSetter "Add/Copy Data Automatically when Editing or Reading". For some reason, I took for granted that setting was about reverse geotagging (automatically retrieving city, country etc and putting them in the corresponding IPTC fields) which off course I wanted. I didn't guess it implied "...to Keywords"; as for the term "Keywords" as header of the table underneath, I suppose it should be "Fields". Thanks for clarifying this!

StarGeek

Quote from: beernoo on February 04, 2020, 03:36:26 AM(automatically retrieving city, country etc and putting them in the corresponding IPTC fields)

I believe that is covered under the "Add Location Info Automatically when Assigning Map Positions" check box in that image, though I haven't double checked that.
"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