Adding values to Subject

Started by ssmith001, September 11, 2013, 11:22:05 AM

Previous topic - Next topic

ssmith001

I'm having a little trouble with the command syntax to add a value to a field. I am trying to figure out how to add a value, in this instance, the last 7 digits before the extension, to the Subject field, but ONLY if that value (2182451) doesn't already exist in the Subject field.

The filename is: 02700042234_2182451.eps

This is the command I'm using:

exiftool '-xmp:subject+<${filename;$_=substr($_,-11,7)}' -overwrite_original *.eps

StarGeek

From the FAQ:
QuoteTo prevent duplication when adding new items, specific items can be deleted then added back again in the same command. For example, the following command adds the keywords "one" and "two", ensuring that they are not duplicated if they already existed in the keywords of an image:

So maybe try something like
exiftool '-xmp:subject-<${filename;$_=substr($_,-11,7)}' '-xmp:subject+<${filename;$_=substr($_,-11,7)}' -overwrite_original *.eps
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

ssmith001

Just tried that and ran it twice, which should in essence remove then add, then remove and add again, resulting in a single value, but it actually added the same value twice, as shown here:

Hunt's Hunt's Premium Pasta Sauce; Chunky Vegetable 26 Oz Grocery 26 Oz; 2182451; 2182451

Oddly enough, subsequent executions didn't result in additional values of 2182451 being added, just the 1st and 2nd executions.

Phil Harvey

Subsequent executions should continue to add the value.

This one is a bit tricky.  From the -tagsFromFile documentation:

            5) The normal behaviour of copied tags differs subtly from that of
            assigned tags for list-type tags.  When copying to a list, each
            copied tag overrides any previous operations on the list.  While
            this avoids duplicate list items when copying groups of tags from
            a file containing redundant information, it also prevents values
            of different tags from being copied into the same list when this
            is the intent.  So a -addTagsFromFile option is provided which
            allows copying of multiple tags into the same list.  ie)

                exiftool -addtagsfromfile @ '-subject<make' '-subject<model' ...

            Other than this difference, the -tagsFromFile and -addTagsFromFile
            options are equivalent.


In your case, the 2nd argument overrides the first.  To prevent this, use -addTagsFromFile.

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