Cool new feature in 12.59 (-fileNUM option)

Started by Phil Harvey, March 28, 2023, 02:15:07 PM

Previous topic - Next topic

Phil Harvey

ExifTool 12.59 (just released) adds a new -fileNUM option which allows metadata to be loaded from multiple files simultaneously.  The new metdata is addressed using the new family 8 group name corresponding to the option used.  (eg. for a file loaded using -file1 the tags are accessed using a file1: group name prefix.)

This allows information from multiple files to be compared and combined in ways that weren't possible with previous versions of ExifTool.

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

greybeard

Well done - just been trying it out (it is a cool feature) - perhaps an example in the specs (or FAQs) might be useful?

Phil Harvey

There are just too many possible ways to use this new feature for me to decide on an example.  Also, it is probably one of those things that will be very rarely used, so I don't know how useful an example would be.  But perhaps I'll add an example or FAQ if some usage or problem comes to the forefront.

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

Phil Harvey

I will be adding a new feature to the -fileNUM option in 12.61 which I would have liked to be able to add to -tagsFromFile except that it wouldn't have been backward compatible for file names containing a dollar sign. (I'm not as worried about backward compatibility for the -fileNUM option because it is such a new option.)  With this version you will be able to use tags in the file name to specify the alternate file, and I'll add this example to the documentation:

            For example, assuming that the OriginalFileName tag has been
            set in the edited file, a command to copy Rights from the
            original file could look like this:

                exiftool -file1 "$originalfilename" "-rights<file1:rights" edited.jpg


In fact, the -fileNUM option makes -tagsFromFile redundant, but of course I'll keep it for backward compatibility and since the syntax is simpler (ie. no family 8 prefixes needed).

One more thing I didn't mention that came with this new feature was the ability to add tags to queued lists on a per-tag basis using the -+TAG<SRCTAG syntax.  This supersedes the -addTagsFromFile option which performed this operation on all tags copied from a specific file.  I have quietly removed -addTagsFromFile from the documentation beginning with version 12.59 (even though it will continue to be supported for backward compatibility).  The -addTagsFromFile option was incongruous because it was applied to all source tags from a given file, but logically the option should have been associated with the target tag being written.  Unfortunately, I realize that the syntax is somewhat confusing (ie. a "+" before the target tag name indicates the value is added to the list of queued values for writing, while a "+" after the target tag name indicates that the queued values should be added to the list of values that already exist in the file), which is part of the reason why I originally implemented -addTagsFromFile instead of doing it this way.

I'm sure this is all as clear as mud, but post your questions here if anyone has any.

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

herb

Hello Phil,

thanks for this new feature. I am starting to go the very first steps with it.

Quote from: Phil Harvey on April 05, 2023, 02:36:47 PMie. a "+" before the target tag name indicates the value is added to the list of queued values for writing, while a "+" after the target tag name indicates that the queued values should be added to the list of values that already exist in the file
But sorry, the info above is not clear to me.
I suggest, it is for listtype tags only.
One "+" is for adding new values to the existing values of the list.
Is the other "+" for adding values without any need of using the -sep option?

Please give an example.
Thanks in advance.
Best regards
herb

Phil Harvey

#5
Setup:

> exiftool -ver
12.60
> exiftool a.jpg -description="some description" -subject=existing
    1 image files updated

All examples start from the above file.

Example 1: Copy 2 tags to the same list-type tag.  Here the second argument overrides the first, and the result overwrites the existing Subject item(s).

> exiftool a.jpg "-subject<filename" "-subject<description"
    1 image files updated
> exiftool a.jpg -subject
Subject                         : some description

Example 2: This time we use +< to add to the existing Subject, but the second argument still overrides the first so the FileName isn't written.

> exiftool a.jpg "-subject<filename" "-subject+<description"
    1 image files updated
> exiftool a.jpg -subject
Subject                         : existing, some description

Example 3: Here we use -+TAG<SRCTAG to add to the queued items, so FileName and Description are both written, but they overwrite the existing Subject.

> exiftool a.jpg "-subject<filename" "-+subject<description"
    1 image files updated
> exiftool a.jpg -subject
Subject                         : a.jpg, some description

Example 4: Use a plus before the tag name to write both FileName and Description, and a +< to add to existing Subject values.
 
> exiftool a.jpg "-subject<filename" "-+subject+<description"
    1 image files updated
> exiftool a.jpg -subject
Subject                         : existing, a.jpg, some description

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

herb

Hello Phil,

thanks for all these detailed examples.

Please allow a question to the following:
Lets assume 2 *.jpg test images with the following values for listtype tag subject:
======== test1.jpg
Subject                         : s11, s12, s13
======== test2.jpg
Subject                         : s21, s22, s23


The command
exiftool.exe -tagsfromfile test2.jpg -xmp-dc:all -+xmp-dc:subject test1.jpggives:
======== test1.jpg
Subject                         : s21, s22, s23, s21, s22, s23
======== test2.jpg
Subject                         : s21, s22, s23

The new feature allows also the following command:
exiftool.exe -tagsfromfile test2 -+xmp-dc:subject test1.jpgBut why does is not add the values of subject?
Where is my misunderstanding?

Thanks for all clarifications in advance
Best regards
herb

Phil Harvey

In the first command you queue the Subject to be copied (implied with -xmp-dc:all), then add the subject again to the queued value.

In the second command there is nothing queued to add to.

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

herb

Hello Phil,

thanks again for your detailed explanations. Now it is clear to me how the "internal copylist" is used.

Playing again with this new feature and also with the -fileNUM feature I have the following questions:

Lets assume we have 3 *.jpg images with the following values for xmp-dc:creator
======== test1.jpg
Creator                         : c11, c12, c13
======== test2.jpg
Creator                         : c21, c22, c23
======== test3.jpg
Creator                         : c31, c32, c33


My goal is to get all creator values into test1.jpg image:

With
exiftool.exe -tagsfromfile @ -xmp-dc:creator -tagsfromfile test2.jpg -+xmp-dc:creator test1.jpgI got the values of creator of files test1 and test2:
======== test1.jpg
Creator                         : c11, c12, c13, c21, c22, c23

Now I tried also to use the -fileNUM feature
exiftool.exe -file1 test3.jpg -tagsfromfile @ -xmp-dc:creator -tagsfromfile test2.jpg -+xmp-dc:creator -+file1:xmp-dc:creator test1.jpgbut I got the same result as above: values c31, c32 and c33 are not copied from test3.jpg

What did I wrong or where is my misunderstanding?

Thanks for your help in advance
Best regards
herb

Phil Harvey

Hi Herb,

This is a bit complex.  I never intended -tagsfromfile to be mixed with -fileNUM.  It is possible, but you need to know some details about how this is implemented to understand what is happening:

1. Arguments after -tagsfromfile apply to copying tags from the specified file.

2. The -fileNum option reads tags into the namespace of the source file, so tags from an alternate file are not available after a -tagsFromFile option for anything other than the source file.  (There would be real order-of-operations issues if I tried to push them into the namespaces of the other -tagsFromFile files.)

3. The argument -+file1:xmp-dc:creator wouldn't work anyway because it tries to copy File1:XMP-dc:Creator to File1:XMP-dc:Creator, but the alternate input files aren't writable.

This command is closest to what you want, but I had to change the order to put the test2.jpg after the File1 tags:

exiftool.exe -file1 test3.jpg -tagsfromfile @ -xmp-dc:creator "-+xmp-dc:creator<file1:creator" -tagsfromfile test2.jpg -+xmp-dc:creator test1.jpg

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

herb

Hello Phil,

thanks for your detailed explanation and thanks for sharing all these ExifTool secrets.

Lets now assume that the sequence copying the tags is important.
What do you think about the following commands: ( I have not tested it)
Command 1 adds an -tagsfromfile @ again
exiftool.exe -file1 test3.jpg -tagsfromfile @ -xmp-dc:creator -tagsfromfile test2.jpg -+xmp-dc:creator
             -tagsfromfile @ -+file1:xmp-dc:creator test1.jpg
Command 2 works "only" with -fileNUM
exiftool.exe -file1 test3.jpg -file2 test2.jpg
             -tagsfromfile @ -xmp-dc:creator -+file2:xmp-dc:creator -+file1:xmp-dc:creator test1.jpg

Thanks again in advance
Best regards
herb.

Phil Harvey

The -+file1:xmp-dc:creator arguments have no effect for the reason I mentioned earlier.

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

herb

Hello Phil,

Aha; now I have it. Thanks again.

Best regards
herb