+ does not work with exiftool -config dirtree.config "-subject<dirtree"

Started by antkent, January 06, 2021, 12:48:48 AM

Previous topic - Next topic

antkent

Parse directory tree and to Subject works great, but overwrites current content.  + does not work, is there a simple solution to add to Subject instead of overwrite?

Also looking for similar solution for exiftool "-Description<subject" which has the same result?

Phil Harvey

+ will work for XMP:Subject because this is a list-type tag.

But Description is not.  To add to Description use "-description<${description} SOME OTHER TEXT"

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

StarGeek

Or in the case of your example,
"-Description<${Description} $Subject"

The braces are optional in this example, but would be needed if the "SOME OTHER TEXT" bumped up against the Description name.
* 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).

antkent

Understood and thanks.  That does not overwrite Description, but also does not put Subject list entries on separate lines in Description.  Is there a solution for this?

Also, sorry I hijacked my own thread.  How would one make this additive and not overwrite: exiftool -config dirtree.config -use MWG "-subject<dirtree" DIR

StarGeek

Quote from: antkent on January 06, 2021, 11:57:29 AM
That does not overwrite Description, but also does not put Subject list entries on separate lines in Description.  Is there a solution for this?

See FAQ #21, options B and D I think.
* 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).

antkent

Thanks Stargeek. I tried to adopt your solution from my other post;  exiftool -sep ## -use MWG "-subject+<${Description;s/\r?\n/##/g}" DIR and it did not work.  I went through that FAQ and the API and struggled with it.

Backing up, my overall goal is to add the Dir tree and Description content to the current Subject content, and I appear to be taking the long road there. 

As the Dir tree solution overwrites Subject:
I use Description as a temporary container while preserving its current content by
Copying it to Subject as a list first
Then store the Dir tree in Subject
Then add Subject (Dir tree) again to Description
And then copy Description back to Subject line by line, which is not working

So if we can solve the exiftool -config dirtree.config "-subject<dirtree" overwrite of Subject I can skip all of that.  Suggestions?

StarGeek

Quote from: antkent on January 06, 2021, 02:09:46 PM
Thanks Stargeek. I tried to adopt your solution from my other post;  exiftool -sep ## -use MWG "-subject+<${Description;s/\r?\n/##/g}" DIR and it did not work.

In what way did it not work?  Did you check the results with the command in FAQ #3?

Here's the example output using that command.  I didn't include the -use MWG option because it doesn't do anything when you write to a non-MWG tag (see MWG tags).  I also used the -j (-json) option because it explicitly shows carriage returns and new lines, as well as separating keywords.
C:\>exiftool -g1 -a -s -Subject -Description y:\!temp\Test4.jpg -json
[{
  "SourceFile": "y:/!temp/Test4.jpg",
  "XMP-dc": {
    "Description": "Word One\r\nWord Two\nWord Three",
    "Subject": "Starting Word"
  }
}]

C:\>exiftool -P -overwrite_original -Sep ## "-Subject+<${Description;s/\r?\n/##/g}" y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -Subject -Description y:\!temp\Test4.jpg -json
[{
  "SourceFile": "y:/!temp/Test4.jpg",
  "XMP-dc": {
    "Description": "Word One\r\nWord Two\nWord Three",
    "Subject": ["Starting Word","Word One","Word Two","Word Three"]
  }
}]
* 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).

StarGeek

Quote from: antkent on January 06, 2021, 02:09:46 PM
So if we can solve the exiftool -config dirtree.config "-subject<dirtree" overwrite of Subject I can skip all of that.  Suggestions?

Adding DirTree to the Subject works as well once I found the config file.
C:\>exiftool -config dirtree.config "-Subject+<Dirtree" y:\!temp\Test4.jpg
Warning: Shift value for XMP-pdf:Subject is not a number - y:/!temp/Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -subject y:\!temp\Test4.jpg
---- XMP-dc ----
Subject                         : Starting Word, Word One, Word Two, Word Three, y:, !temp


The warning can be safely ignored as XMP-pdf:Subject does not exist in the file.

The one caveat is that there must be a directory path.  You can't CD to the directory and use a dot to indicate that directory.  The Directory tag, which DirTree uses, is based upon the directory indicated in the command line.
* 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).

antkent

Sorry, to be clear: exiftool -sep ## -use MWG "-subject+<${Description;s/\r?\n/##/g}" DIR works great. 

When I tried to adopt it in reverse: exiftool -sep ## -use MWG "-Description<${subject;s/\r?\n/##/g}" DIR it works (without the +) but the Subject content is written to Description as single line, and of course with the ## as a separator.  I tried to get it to write each Subject entry on a different line in Description but could not.  So it did not work, because I am a Newbie:-)  Also, it overwrote teh current Description instead o adding to it (as + threw the error "Warning: No writable tags set from").

That said, I do not need it to work, if I can get  -config dirtree.config "-subject<dirtree" to NOT overwrite the current Subject, but add to it.

Regardless, this tool and your help has solved many issues for my too massive pile of photos and scans.

StarGeek

Quote from: antkent on January 06, 2021, 09:21:11 PM
That said, I do not need it to work, if I can get  -config dirtree.config "-subject<dirtree" to NOT overwrite the current Subject, but add to it.

As I show in the post above, it works.

Show me the exact command you are using.  Copy/paste it here.
* 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).

antkent

Got it. Had the + in wrong place.  Guess I was a bit distracted for some reason today...

Thanks again for everything. Next up is SDF/CSV to EXIF.