Replacing a tag with language sub-tags

Started by herb, May 16, 2013, 12:01:54 PM

Previous topic - Next topic

herb

Hello Phil,

I am working with exiftool 9.28 on a windows XP system using the standalone version of exiftool.

I have some *.jpg images with -xmp:rights tag that has also subtags for english, german and maybe other languages.

I want to delete all subtags except the german one with:
exiftool -tagsfromfile image.jpg
         -xmp:rights="" -xmp:rights-x-default<xmp:rights -xmp:rights-de<xmp:rights-de
         image.jpg


This command is working.
But I also want to replace the string for the german language subtag within the same command with:
exiftool -tagsfromfile image.jpg
         -xmp:rights = "" -xmp:rights-x-default < xmp:rights -xmp:rights-de < xmp:rights-de
         -xmp:rights-de -= oldvalue -xmp:rights-de = newvalue
         image.jpg


In order to make it complicated, the values for -xmp:rights-de contain also a quotation mark - character "
Because this character is also used to border the values the character " is sent as \" and the above command may look like
exiftool -tagsfromfile image.jpg
         -xmp:rights = "" -xmp:rights-x-default < xmp:rights -xmp:rights-de < xmp:rights-de
         -xmp:rights-de -= "old\"value" -xmp:rights-de = "new\"value"
         image.jpg


In case of the new-value contains such a quotation mark the tag is deleted.
Sometimes only the subtag -xmp:rights-de is deleted.
Sometimes the complete tag is deleted.
But I do not have any rule which happens when.

Is it an error or what do I wrong.

Best regards
Herb

Phil Harvey

Hi Herb,

Quote from: herb on May 16, 2013, 12:01:54 PM
But I also want to replace the string for the german language subtag within the same command with:
exiftool -tagsfromfile image.jpg
         -xmp:rights = "" -xmp:rights-x-default < xmp:rights -xmp:rights-de < xmp:rights-de
         -xmp:rights-de -= oldvalue -xmp:rights-de = newvalue
         image.jpg

I am not clear on exactly what you are trying to do.

1) does the source -tagsfromfile file always contain rights information?

2) does the xmp:rights-de value of "oldvalue" only exist in some of the source -tagsfromfile files?

- 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 reply.

The command we talk about is generated by my VisualBasic application.
Using some options in this application lead to the - lets say - unusual combination of options with the goal:
- only tags -xmp:rights-x-default and -xmp:rights-de should be available in the image file.
  Other language subtags - in case of they exists - shall be removed.
- Within the same step also a specific value of -xmp:rights-de is to be replaced.


In order to answer all your questions I did the following tests:

I prepared a *.jpg file, which does not contain any XMP tag with
  -xmp:rights = "baserights" and -xmp:rights-de = "de-rights"


Then I used the following command to insert 2 quotation marks into xmp:rights-de
under replace conditions:
  exiftool.exe -tagsfromfile prepared_file.jpg
               -xmp:rights = ""  -xmp:rights-x-default < xmp:rights -xmp:rights-de < xmp:rights-de
               -xmp:rights-de -= "de-rights" -xmp:rights-de = "de\"-\"rights"
               prepared_file.jpg


Please notice the filename for -tagsfromfile and the destination filename are identical.

The result is: -xmp:rights is unchanged and -xmp:rights-de is deleted.

To get a better overview I repeated the test in following combinations:

a) With the above command an additional option was sent: -xmp:rights-en < xmp:rights-en
    This language subtag does not exist.

b) Instead of the quotation mark another ASCII character was sent

c) No replace of -xmp:rights-de was requested (-xmp:rights-de -= "de-rights" was not part of the command)
   c1)  for new-value a string with quotation mark was used
   c2)  for new-value a string without quotation mark was used
   I did this because I thought, that the quotation mark will cause the described problem.

d) The copying of existing -xmp:right tags from -tagsfromfile was not requested
   d1)  replace of -xmp:rights-de was requested
   d2)  replace of -xmp:rights-de was not requested


The above described error/problem occurs only in combination of
- copy -xmp:rights-xx tags from -tagsfromfile and
- value of -xmp:rights-de is to be replaced

I hope this answers your questions
Best regards
Herb

Phil Harvey

Hi Herb,

The escaping of quotes is something you will have to figure out.  You might have to double escape them if running the command from inside visual basic.  (Visual basic will probably unescape one level, and the command processor may unescape again.)

Also, why the spaces around the "=" signs?  These shouldn't be there.

To erase all existing languages you should write XMP:Rights.  Don't write XMP:Rights-x-default.

From the XMP documentation:

Individual languages for lang-alt tags are accessed by suffixing the tag name with a '-', followed by an RFC 3066 language code (ie. "XMP:Title-fr", or "Rights-en-US"). (See http://www.ietf.org/rfc/rfc3066.txt for the RFC 3066 specification.) A lang-alt tag with no language code accesses the "x-default" language, but causes other languages for this tag to be deleted when writing. The "x-default" language code may be specified when writing to preserve other existing languages (ie. "XMP-dc:Description-x-default"). When reading, "x-default" is not specified.

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