Author Topic: Problem with TAG= and TAG+= for xmp-lr:HierarchicalSubject  (Read 4437 times)

anvoit

  • Newbie
  • *
  • Posts: 3
Problem with TAG= and TAG+= for xmp-lr:HierarchicalSubject
« on: April 02, 2010, 03:20:35 PM »
I have a problem with the use of TAG= and TAG+= command line arguments using exiftool. At least I don't fully understand their use.

Let's make an example. Let's assume a JPEG file without any XMP tags.

First I create an initial set of xmp-lr:HierarchicalSubject tags:
Code: [Select]
exiftool -xmp-lr:HierarchicalSubject=AAA -xmp-lr:HierarchicalSubject=BBB

Now I wanna delete all old xmp-lr:HierarchicalSubject tags and replace them with a set of new one:
Code: [Select]
exiftool -xmp-lr:HierarchicalSubject= -xmp-lr:HierarchicalSubject+=CCC -xmp-lr:HierarchicalSubject+=DDD

But this doesn't work for me, as the tags AAA and BBB are not deleted.

If I do the following:
Code: [Select]
exiftool -xmp-lr:HierarchicalSubject= -xmp-lr:HierarchicalSubject=CCC -xmp-lr:HierarchicalSubject=DDD
then it works.

Of course I understand that I could use the last example. But in my code, I conditionally delete all tags and wanna add some more tags later. So in this case it would be fortunate optionally to use TAGS= to delete the tags and always use TAG+= to add the tags.

So what I'm doing wrong here? And what is possible? In general, for me it's not clear when to use TAG= and TAG+= to add tags.

Thanks,

Andreas

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16664
    • ExifTool Home Page
Re: Problem with TAG= and TAG+= for xmp-lr:HierarchicalSubject
« Reply #1 on: April 02, 2010, 03:54:43 PM »
Hi Andreas,

This is a common source of confusion.  FAQ number 17 deals with list-type tags for this reason.

Most people get confused because they don't realize that += applies to keywords that already exist in the file, not to ones you are writing.  So if you use +=, you are telling exiftool that you want to keep the existing values.  In this context, "-keywords= -keywords+=value" makes no sense.  If you just say "-keywords=one -keywords=two", then the existing keywords are deleted and replaced by "one" and "two".  I know it isn't intuitive but I think it should provide the functionality you need.

Please let me know if you are still confused after reading this and FAQ 17.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

anvoit

  • Newbie
  • *
  • Posts: 3
Re: Problem with TAG= and TAG+= for xmp-lr:HierarchicalSubject
« Reply #2 on: April 03, 2010, 08:48:49 AM »
Hi Phil,

thanks, now it's clear what's going on and how it is implemented.

Yes, it's not intuitive due to the following reason: let's assume that a tag isn't present at all. When you then use TAG+=VALUE the tags gets created and VALUE will be the first element of the list. Any subsequent TAG+=VALUE will add the values to the list.

But when I first delete the complete TAG (list) with TAG= and the use TAG+=VALUE, the TAG list doesn't get deleted first, even though it's semantically the same like when the TAG isn't available right from the start.

Sure, I can program around this and I already did now, but it makes the code more complex because I need special cases for this. In my humble opinion, it would be nice if exiftool would do it. But maybe thereare good arguments why this is not possible that I don't know.
Maybe you wanna think about what could be done here. I think it wouldn't be a problem to change this behaviour as right now nobody will use "TAG= TAG+=" because this combination doesn't do anything intuitive.

Thanks,

Andreas

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16664
    • ExifTool Home Page
Re: Problem with TAG= and TAG+= for xmp-lr:HierarchicalSubject
« Reply #3 on: April 03, 2010, 10:08:52 AM »
Hi Andreas,

Thanks for the suggestion, I'll think about this.  But one thing I like about the current behaviour is that it errs towards the safer result of preserving existing values.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).