How do I write to list type?

Started by dwlott, January 18, 2024, 08:37:00 AM

Previous topic - Next topic

dwlott

Hello again,
How do I write to list type from other tags in file? I think the below code is writing only one value.
I am tryin this to add to the list:
-+Keywords<${Make}
-+Keywords<${Model}
e:\mySourceFolder\SrcFile_1.JPG
After the command, reading with -struct returns:
[Nikon,D70]

I am trying this to replace the list:
-Keywords<${Make}
-+Keywords<${Model}
e:\mySourceFolder\SrcFile_1.JPG

Here I am trying to write flattened text.
-Keywords+="{Ford,F148}" e:\mySourceFolder\PA110003_03.JPGDoes not work

-Keywords=Make
-Keywords+=Model
e:\mySourceFolder\SrcFile_1.JPG

After the command, reading with -struct returns:
Quote[Nikon,D70]
I was expecting a pipe instead of a comma between Nikon and D170
 


Phil Harvey

I don't understand what you are trying to do.  You have done a number of different things.  Also "does not work" is not a good description of the problem.

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

dwlott


How do I add to the Keywords list, when there is already items in the list?
-+Keywords<${Make}
-+Keywords<${Model}
e:\mySourceFolder\SrcFile_1.JPG
This command seems to replace the Keywords list instead of adding to it. 

StarGeek

See FAQ #17, List-type tags, line that starts "Note that as with "=" "

Also, if you're not doing any of the Advanced formatting features or combining tags with a static string, you don't need to use braces and dollar signs, and it's usually better not to.  See Common Mistake #5b
* 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).

dwlott

Still trying to understand how to add to list type lists.
I am testing with the following code, first writing values to tags.
-Reference1=Value1
-Reference2=Value2
-Reference3=Value3
-Reference4=Value4
-Reference5=Value5
-Reference6=Value6
e:\mySourceFolder\SrcFile_1.JPG

At this point, there is nothing in the Keywords tag.  I'm using this code to copy from existing tags to the Keywords list.
-+Keywords<${Reference1}
-+Keywords<${Reference2}
-+Keywords<${Reference3}
e:\mySourceFolder\SrcFile_1.JPG
Using this command to query.
-sep
//
-f
-T
-Directory
-FileName
-Keywords
-Reference1
-Reference2
-Reference3
-Reference4
-Reference5
-Reference6
e:\mySourceFolder
The keywords value returns
Value1//Value2//Value3As I expected.

Now attempting to add to the Keywords list with this command.
-+Keywords<${Reference4}
-+Keywords<${Reference5}
-+Keywords<${Reference6}
e:\mySourceFolder\SrcFile_1.JPG

After that command, using the same query command as above, the Keywords value returns:
Value4//Value5//Value6
I expected Value1//Value2//Value3//Value4//Value5//Value6or possibly Value4//Value5//Value6//Value1//Value2//Value3
Thanks again for your help StarGeek.

Phil Harvey

You need to use +< to add to the keywords already in the file:

-+Keywords+<${Reference4}
-+Keywords+<${Reference5}
-+Keywords+<${Reference6}
e:\mySourceFolder\SrcFile_1.JPG

The first + adds to the queued keywords, and the second + adds to the keywords already in the file.

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

dwlott

Thank you for helping me understand how to add to list-type tags.
Please also help me know how to prevent duplicates using the -api nodupes feature.  I'm trying the two commands below, but the Keywords list loads with duplicate values.

-api
nodupes
-+Keywords+<${Reference1}
-+Keywords+<${Reference2}
-+Keywords+<${Reference3}
e:\mySourceFolder\SrcFile_1.JPG

-+Keywords+<${Reference1}
-+Keywords+<${Reference2}
-+Keywords+<${Reference3}
-api
nodupes
e:\mySourceFolder\SrcFile_1.JPG

Phil Harvey

The NoDups (not NoDupes!) option only removes duplicates from the queued list items.  You may still end up with duplicates if you are adding to existing values in the file and the file contained one or more of the item(s) you are writing.

To remove all duplicates like this you need to rewrite all items (ie. copy back the original keywords instead of using +<):

-api
nodups
-Keywords<keywords
-+Keywords<Reference1
-+Keywords<Reference2
-+Keywords<Reference3
e:\mySourceFolder\SrcFile_1.JPG

Also, it is more efficient to copy tags directly if no string manipulations are necessary (see common mistake 5b).

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