NoDups(1) deletes tags when no duplicates

Started by msbc, July 12, 2020, 12:46:12 AM

Previous topic - Next topic

msbc

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

StarGeek

From the docs on the -m (ignoreMinorErrors) option
   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.
* 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).

msbc

Teach me to read the fine print in the docs!

Thanks
- Mark

herb

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

StarGeek

I'm not sure I follow.  Do you have an example command and tag data?
* 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).

herb

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

StarGeek

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, it won't return undefined, it returns an empty string, which now overwrites the original keywords.
* 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).

herb

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

Phil Harvey

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

herb

Hello Phil,

thanks for your detailed description.

Best regards
herb