News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Separation

Started by Kugelblitz, July 10, 2020, 03:31:18 AM

Previous topic - Next topic

Kugelblitz

Hello

I messed up my Photo library so all Tags are not really separated anymore.
The commas show up but several Programs like digikam or Windows Explorer identify all the Tags/Keywords as a single keyword.
Which gives me a single long Tag for each Photo in the Photo library.

Like:
XPKeywords : "Arzheim, DEU, Deutschland, Garten, Koblenz, PWS14, Rheinland-Pfalz, Terrasse" all in one Tag



Now I try to separte them again.
exiftool -sep ", " -@ w-separate-tags-by-comma.args -overwrite_original -forcewrite=exif -r -m -P -k -v -NoDubs -iptc:all


with this Args file "w-separate-tags-by-comma.args"
-XMP:Subject<${XMP:Subject;s/\;/\,/g}
-XMP-lr:HierarchicalSubject<${XMP-lr:HierarchicalSubject;s/\;/\,/g}
-XMP-digiKam:TagsList<${XMP-digiKam:TagsList;s/\;/\,/g}
-TagsList<${TagsList;s/\;/\/g}
-XMP:LastKeywordXMP<${XMP:LastKeywordXMP;s/\;/\,/g}
-XMP:LastKeywordIPTC<${XMP:LastKeywordIPTC;s/\;/\,/g}
-KeywordIPTC:Keywords<${KeywordIPTC:Keywords;s/\;/\,/g}
-IPTC:Keywords<${IPTC:Keywords;s/\;/\,/g}
-IPTC:CatalogSets<${IPTC:CatalogSets;s/\;/\,/g}
-keywords<${keywords;s/\,/\;/g}
-RegionName<${RegionName;s/\;/\,/g}
-RegionPersonDisplayName<${RegionPersonDisplayName;s/\;/\,/g}
-IFDO:XPKeywords<${IFD0:XPKeywords;s/\s+,\s+|,\s+|\s+,/,/g;}
-XPKeywords<${XPKeywords;s/\;/\,/g}


To check it I have used this command
exiftool -sep " <|> " -TagsList -LastKeywordIPTC -XPKeywords -XMP:Subject -IPTC:Keywords -XMP:LastKeywordXMP  -Categories -HierarchicalSubject -CatalogSets -k -s -G -a -u -g1 -charset DOSlatin1 FILENAME

So when I run that I get this result:
---- IFD0 ----
XPKeywords                      : Arzheim, DEU, Deutschland, Garten, Koblenz, PWS14,   Rheinland-Pfalz, Terrasse
---- XMP-microsoft ----
LastKeywordIPTC                 : Arzheim, DEU, Deutschland, Garten, Koblenz, PWS14,   Rheinland-Pfalz, Terrasse
LastKeywordXMP                  : Garten <|> PWS14 <|>   Terrasse
---- XMP-acdsee ----
Categories                      : Arzheim, DEU, Deutschland, Garten, Koblenz, PWS14,   Rheinland-Pfalz, Terrasse
---- XMP-dc ----
Subject                         : Garten <|> PWS14 <|>   Terrasse
---- XMP-digiKam ----
TagsList                        : Arzheim, DEU, Deutschland, Garten, Koblenz, PWS14,   Rheinland-Pfalz, Terrasse
---- XMP-lr ----
HierarchicalSubject             : Arzheim <|> DEU <|> Deutschland <|> Garten <|> Koblenz <|> PWS14 <|>   Rheinland-Pfalz <|> Terrasse
---- XMP-mediapro ----
CatalogSets                     : Arzheim, DEU, Deutschland, Garten, Koblenz, PWS14,   Rheinland-Pfalz, Terrasse
---- IPTC ----
Keywords                        : Garten <|> PWS14 <|>   Terrasse
CatalogSets                     : Arzheim <|> DEU <|> Deutschland <|> Garten <|> Koblenz <|> PWS14 <|>   Rheinland-Pfalz <|> Terrasse


Notice that IFD0:XPKeywords, XMP-acdsee:Categories,  XMP-mediapro:CatalogSets are not showing the separator <|>
And... when I use that command on a file that does not have IFD0:XPKeywords they show up afterwards but with no content.
So how can they properly be separated?

Stay healthy and Thank you for your help.



Phil Harvey

Only List-type tags are stored separately in the file.  Tags stored as simple strings are not affected by the -sep option.  Check the Tag Name documentation to see which tags are List-type (they will have a "+" after their Format code (eg "string+").

- 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 ($).

Kugelblitz

Thank You Phil for the hint.
Have looked it up.

XMP-acdsee:Categories          string/      (sep does not show the seperator)
XMP-mediapro:CatalogSets         string+      (sep shows the seperator)
IPTC:CatalogSets            string[0,256]+   (sep shows the seperator)
XMP-digiKam:TagsList            string+      (sep shows the seperator)
XMP-microsoft:LastKeywordIPTC      string+      (sep shows the seperator)

Can not find: IFDO:XPKeywords

So the list types "string+" show the Separator - I have adjusted the code and it works now.

Just the Separator for XMP-acdsee:Categories does not show up.
In the Tag Name documentation it has a "string/" - what does the "/" stand for?

Here is the Code that works so far.
exiftool -sep " <|> " -Subject -HierarchicalSubject -TagsList -Categories -LastKeywordXMP -LastKeywordIPTC -Keywords -CatalogSets -RegionName -RegionPersonDisplayName -XPKeywords -k -s -G -a -u -g1 -charset DOSlatin1 FILENAME
with this Args file "w-separate-tags-by-comma.args"


-XMP:Subject<${XMP:Subject;s/\;/\,/g}
-XMP-digiKam:TagsList<${XMP-digiKam:TagsList;s/\;/\,/g}
-XMP:LastKeywordXMP<${XMP:LastKeywordXMP;s/\;/\,/g}
-XMP:LastKeywordIPTC<${XMP:LastKeywordIPTC;s/\;/\,/g}
-XMP-lr:HierarchicalSubject<${XMP-lr:HierarchicalSubject;s/\;/\,/g}
-IPTC:Keywords<${IPTC:Keywords;s/\;/\,/g}
-IPTC:CatalogSets<${IPTC:CatalogSets;s/\;/\,/g}
-IFDO:XPKeywords<${IFD0:XPKeywords;s/\s+,\s+|,\s+|\s+,/,/g;}
-XMP-mediapro:CatalogSets<${XMP-mediapro:CatalogSets;s/\;/\,/g}
-XMP-acdsee:Categories<${XMP-acdsee:Categories;s/\;/\,/g}
-RegionName<${RegionName;s/\;/\,/g}
-RegionPersonDisplayName<${RegionPersonDisplayName;s/\;/\,/g}



Somehow it does not make sense to have the same Tags over and over again in different XMP or IPTC Stings.
One should be enough.
Do you have a recommendation which String (XMP:Subject, IPTC:Keywords and so on... ) is best to use.
I mean that most Software reads and writes... and has the least limitations.
And what Character (Comma, Semicolon) is best to use as a Separator? ? Would be nice if there would be a defined character just for string Separation?

StarGeek

Quote from: Kugelblitz on July 10, 2020, 06:19:14 PM
Can not find: IFDO:XPKeywords

IFD0 is part of the EXIF group.  It's a tag created by Microsoft back in the XP era and only a very few programs outside of Windows use it.  Windows saves it as a semicolon separated string, so the -sep option will not work with it.

For Windows to properly read it, you example list should be
Arzheim;DEU;Deutschland;Garten;Koblenz;PWS14;Rheinland-Pfalz;Terrasse

QuoteJust the Separator for XMP-acdsee:Categories does not show up.
In the Tag Name documentation it has a "string/" - what does the "/" stand for?

You should be able to mouse over the slash on the tag page to see what they stand for, but otherwise all options are listed on the main tag page.  In this case, the slash stands for Avoid.  Exiftool will avoid writing these tags unless specifically listed.  In most cases, this is because there is a more common tag with the same name, but I believe all the XMP-acdsee tags are set to avoid because many of them are duplicates of far more common tags and ACDsee is usually the only software to read them.  See Phil's mini-rant under the ACDSee tags.

QuoteSomehow it does not make sense to have the same Tags over and over again in different XMP or IPTC Stings. One should be enough.



QuoteDo you have a recommendation which String (XMP:Subject, IPTC:Keywords and so on... ) is best to use.
I mean that most Software reads and writes... and has the least limitations.

With most modern software, you can stick to just the XMP tags and use the IPTC Photo Metadata Standard as a guideline. This is what programs such as Lightroom or Digikam, as well as Windows/Mac/Linux OS will read/write.  If you need compatibility with some older software, use the older IPTC IIM/Legacy tags as well.  In most cases, you don't need to worry about EXIF tags as those are usually set by the camera that took the picture.  GPS tags would be the exception to that.

QuoteAnd what Character (Comma, Semicolon) is best to use as a Separator? ? Would be nice if there would be a defined character just for string Separation?

The thing to remember is that there is no separator for list type tags.  Each tag is completely separate from the others.  As an example,  here's how keywords are saved in the XMP:Subject tag
  <dc:subject>
   <rdf:Bag>
    <rdf:li>first keyword</rdf:li>
    <rdf:li>Third Keyword</rdf:li>
    <rdf:li>&quot;Forth keyword&quot;</rdf:li>
    <rdf:li>Smith, John</rdf:li>
   </rdf:Bag>
  </dc:subject>


You only need to worry about using the -sep option if you have accidentally saved multiple keywords as one, long keyword.  See FAQ #17 for details.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Kugelblitz

Hello StarGeek,

thank you thank you very much for your helpful reply.

You are right I should drop XPKeywords and probably XMP-acdsee too.
Maybe it would be best to merge all other Subject Tags into the XMP:Subject without duplicates and then clear or remove the old once, XPKeywords and XMP-acdsee too. 

Think I open a new Post for this action.

Kugelblitz

The current args file works but adds empty tags if they not already exist.
To prevent that I wrote a "if defined" and "execute" in the args file.

But no only the first condition is properly executed, the others are skipped.
How can I run it on all conditions that apply?

exiftool -Sep ", " -@ w-separate-tags-by-comma.args -common_args -m -P -k -overwrite_original_in_place FILENAME

w-separate-tags-by-comma.args
# Separate Tags only if the Tag exist.
# Additional keywords added with another program will not be deleted
#
# use exiftool -@ keywordsandstuff.args -common_args -m -P -overwrite_original_in_place photo.jpg
# instead of photo.jpg, use eg *.jpg,  -ext jpg . or  *.mov.xml
#
-if
defined $XMP-lr:HierarchicalSubject
-XMP-lr:HierarchicalSubject<${XMP-lr:HierarchicalSubject;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP-dc:Subject
-XMP-dc:Subject<${XMP-dc:Subject;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $IPTC:Keywords
-IPTC:Keywords<${IPTC:Keywords;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP:LastKeywordXMP
-XMP:LastKeywordXMP<${XMP:LastKeywordXMP;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP-digiKam:TagsList
-XMP-digiKam:TagsList<${XMP-digiKam:TagsList;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP:LastKeywordIPTC
-XMP:LastKeywordIPTC<${XMP:LastKeywordIPTC;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $IPTC:CatalogSets
-IPTC:CatalogSets<${IPTC:CatalogSets;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $IFDO:XPKeywords
-IFDO:XPKeywords<${IFD0:XPKeywords;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP-mediapro:CatalogSets"
-XMP-mediapro:CatalogSets<${XMP-mediapro:CatalogSets;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP-acdsee:Categories
-XMP-acdsee:Categories<${XMP-acdsee:Categories;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP-mwg-rs:RegionName
-XMP-mwg-rs:RegionName<${XMP-mwg-rs:RegionName;s/\s+,\s+|,\s+|\s+,/, /g;}
-execute
#
-if
defined $XMP-MP:RegionPersonDisplayName
-XMP-MP:RegionPersonDisplayName<${XMP-MP:RegionPersonDisplayName;s/\s+,\s+|,\s+|\s+,/, /g;}
#

Phil Harvey

I don't understand.  Your -if condition isn't necessary if you don't use the -m option.  Why are you using -m?

Also, I don't know what you mean by "the others are skipped".  They shouldn't be.

- 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 ($).

Kugelblitz

Hello Phil,

thank you for the hint. It works without the -m option and also without the conditions.

exiftool -Sep ", " -@ w-separate-tags-by-comma.args -common_args -P -k -overwrite_original_in_place FILENAME

w-separate-tags-by-comma.args
# Separate Tags.
# Additional keywords added with another program will not be deleted
#
# use exiftool -@ keywordsandstuff.args -common_args -m -P -overwrite_original_in_place photo.jpg
# instead of photo.jpg, use eg *.jpg,  -ext jpg . or  *.mov.xml
#
-XMP-lr:HierarchicalSubject<${XMP-lr:HierarchicalSubject;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP-dc:Subject<${XMP-dc:Subject;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-IPTC:Keywords<${IPTC:Keywords;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP:LastKeywordXMP<${XMP:LastKeywordXMP;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP-digiKam:TagsList<${XMP-digiKam:TagsList;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP:LastKeywordIPTC<${XMP:LastKeywordIPTC;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-IPTC:CatalogSets<${IPTC:CatalogSets;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-IFDO:XPKeywords<${IFD0:XPKeywords;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP-mediapro:CatalogSets<${XMP-mediapro:CatalogSets;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP-acdsee:Categories<${XMP-acdsee:Categories;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP-mwg-rs:RegionName<${XMP-mwg-rs:RegionName;s/\s+,\s+|,\s+|\s+,/, /g;}
#
-XMP-MP:RegionPersonDisplayName<${XMP-MP:RegionPersonDisplayName;s/\s+,\s+|,\s+|\s+,/, /g;}
#