Hello Phil,
after working a little bit with alternate-language list-tags (see: exiftool.org/forum/index.php/topic,10407.0.html (https://exiftool.org/forum/index.php/topic,10407.0.html) ) where we discussed "missing list elements" I was interested in how listtype tags - e.g.: iptc:by-line or xmp-dc:creator - behave when I also (try to) use/write empty list elements.
An empty list element for me is a string with length 0.
I tested on my Windows 7 system using exiftool 11.70 that I started in DOS-box.
To test the results of my writing commands I used different separator-characters for reading and writing or I used option -struct for display.
( And sorry that this post has become a little bit long.)
Commands like
exiftool.exe -sep ? -iptc:by-line=a??b??c -xmp-dc:creator=a??b??c test.jpg
exiftool.exe -sep ? -iptc:by-line=??a??b??c?? -xmp-dc:creator=??a??b??c?? test.jpg
exiftool.exe -sep ? -iptc:by-line=?? -xmp-dc:creator=?? test.jpg
showed that it is possible
- to create empty elements in between non-empty elements
- to create empty elements even at list begin, as long as a non-empty element is at end of the list
- for tag=?? (which is separator) this is handled as "character" not as separator character
- (1) for tag=??a??b??c?? it looks like that the trailing separators ?? are ignored
The more astonished I was that empty elements are also possible in case of adding elements to a list.
The command sequence
exiftool.exe -sep ? -iptc:by-line=??a??b??c?? -xmp-dc:creator=??a??b??c?? test.jpg
exiftool.exe -sep ? -iptc:by-line+=e??f -xmp-dc:creator+=e??f test.jpg
not only added the elements e and f, but also an empty element in between it.
With display command
exiftool.exe -struct -iptc:all test.jpg
we can see this (only the interesting tags are listed, others are not given here)
By-line : [,,a,,b,,c,e,,f]
This showed that for case (1) the trailing ?? are really ignored.
The command sequence
exiftool.exe -sep ? -iptc:by-line=??a??b??c?? -xmp-dc:creator=??a??b??c?? test.jpg
exiftool.exe -sep ? -iptc:by-line+=e??f -xmp-dc:creator+=e??f test.jpg
exiftool.exe -sep ? -iptc:by-line-=e??f -xmp-dc:creator-=e??f test.jpg
removed elements e and f and also all empty elements
exiftool.exe -sep # -iptc:all -xmp:all test.jpg
showed
By-line : a#b#c
Creator : a#b#c
That means all empty elements can be removed with
exiftool.exe -tag-=x??y with x and y being strings that do not exist in the list.
Ok, I have to agree that I do not have any usecase for the empty list-elements, but it is very interesting from technical point of view.
So please do not misunderstand my following question:
Is that really all possible by design?
Because of the "unchanged behaviour" in all testcases I think the answer will be yes.
Thanks in advance
Best regards
Herb
Hi Herb,
First, let me point out that your previous tests with lists of lang-alt lists is very different, and much more complex than the simple lists you are using here.
When adding elements to a list, it is the behaviour of the ListSplit option that you are uncovering here. ListSplit uses the Perl "split" function, which by default removes trailing null entries. I could change this easily if there was a need.
The second thing you noticed is that ListSplit does nothing if there are less than 2 entries returned by the "split" function. I did it this way only because I didn't think of empty list elements when I wrote the code. Again, this is easy to change.
As far as deleting empty elements, this is as easy as: exiftool -iptc:by-line-=
In the past, I have not endorsed the possibility of empty tag values. However, with the new ^= operator I have introduced a way to add these. For example, -xmp-dc:creator+^= will add an empty entry to the end of the list.
In light of this new support, I should probably change the behaviour of the ListSep as well to properly deal with empty list items.
Thanks for prompting me to think about this.
- Phil