ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: msbc on July 12, 2020, 12:46:12 AM

Title: NoDups(1) deletes tags when no duplicates
Post by: msbc on July 12, 2020, 12:46:12 AM
I'm seeing that when no duplicates exist then NoDups(1) deletes all entries in the list:
exiftool -keywords a.jpg
Keywords                        : Arctic, Norway, Spitsbergen, Svalbard, bears, ice, mammal, pack ice, polar bear, snow

exiftool -m -q -sep '##' '-keywords<${keywords;NoDups(1)}' a.jpg
exiftool -keywords a.jpg
Keywords                        :

When there is at least one duplicate the command works as expected.

macOS: 10.15.5
exiftool -ver: 11.85
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: StarGeek on July 12, 2020, 02:45:10 AM
From the docs on the -m (ignoreMinorErrors) option (https://exiftool.org/exiftool_pod.html#m--ignoreMinorErrors)
   Note that this causes missing values in -tagsFromFile, -p and -if strings to be set to an empty string rather than an undefined value.

'-keywords<keywords' is an implied -TagsFromFile and when -m is added, the NoDups(1) will be set to a blank string instead of undefined.  Remove it and the command will do what you want.
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: msbc on July 12, 2020, 03:04:09 AM
Teach me to read the fine print in the docs!

Thanks
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: herb on July 15, 2020, 08:51:38 AM
Hello everybody,

sorry to give my 2 cents to this problem.

But I have seen that the tag is not deleted, but an empty list is created/written.
Should the listtype-tag be deleted?

Best regards
herb
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: StarGeek on July 15, 2020, 11:46:16 AM
I'm not sure I follow.  Do you have an example command and tag data?
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: herb on July 15, 2020, 02:33:01 PM
Hello StarGeek,

sorry, that I was not clear enough.
In first post of this topic, msbc gives a good example. The output of his display-command shows that keywords exists and that keywords is empty.
I had expected that keywords is deleted (does not exist) after "NoDups(1)" command.

Best regards
herb
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: StarGeek on July 15, 2020, 02:51:02 PM
Normally, NoDups(1) would return Undef in the event there were not any duplicates.  That way the file wouldn't be rewritten if there wasn't a change. But because of the -m (ignoreMinorErrors) option (https://exiftool.org/exiftool_pod.html#m--ignoreMinorErrors), it won't return undefined, it returns an empty string, which now overwrites the original keywords.
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: herb on July 16, 2020, 04:51:34 AM
Hello StarGeek,

thanks for your detailed explanation. It is all understood.
Usuallay -keywords=   (which is -keywords=<empty string returned by NoDups(1)> will remove the keywords tag, so that it does not exists anymore.
But why does it exist afterwards as "an empty listtype tag" ?

Best regards
herb
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: Phil Harvey on July 16, 2020, 07:36:36 AM
Writing an empty string to any tag will do this.  The confusion arises because ExifTool uses the -TAG= syntax to indicate that you want to delete the tag.  So it is actually very difficult to write an empty string from the command line.  (That is why I added the -TAG^= syntax.)  But using -m with an advanced formatting expression that returns undef (or just an expression that returns an empty string) is one way to do it.

- Phil
Title: Re: NoDups(1) deletes tags when no duplicates
Post by: herb on July 16, 2020, 09:18:51 AM
Hello Phil,

thanks for your detailed description.

Best regards
herb