-stay_open input formatting

Started by ribtoks, August 23, 2017, 05:15:33 AM

Previous topic - Next topic

ribtoks

Hello

I have a bunch of newbie questions regarding the format of the arguments when using glorious Exiftool with -stay_open magic and writing actual arguments to stdin.

So the use-case:
Set XMP, IPTC, EXIF description, title and keywords (in UTF-8) for 2 images (lets say file1.jpg and file2.jpg)
(also for this example we don't care about possibilities of any standard to handle UTF-8)

My current assumption (simplified):

Starting Exiftool with:
exiftool.exe -stay_open True -@ -

Data written to stdin separated by "\n":

-charset
FileName=UTF8
-XMP:Title=XXXXX
-IPTC:ObjectName=YYYYYYY
-EXIF:ImageDescription=ZZZZZZZ
/path/to/file1.jpg
-XMP:Title=XXXXX
-IPTC:ObjectName=YYYYYYY
-EXIF:ImageDescription=ZZZZZZZ
-XMP:Subject="Keyword1", "Keyword2", "Keyword3"
/path/to/file2.jpg
-stay_open
False


My actual questions:

1. Can it be done for several files as I wrote? Like iteratively options for each file (ending with path to that file).
2. Is that correct format in the assumption? Or maybe do I need to split -XMP:Title and XXXXX to separate lines?
3. How to write XXXXX, YYYYYY and ZZZZZZ if they are UTF-8 strings with spaces and, possibly, newlines?
4. How to write keywods? A keyword is a UTF-8 string with spaces. Do I need to put them into 1 line or to put each one to the separate line or what?

Sorry for a lot of questions and thanks in advance!

StarGeek

I've never used the -stay_open option but you'll want to take a close look at the -@ argfile docs. 

Your example data is the same as if it was all a single command:
exiftool -charset FileName=UTF8 -XMP:Title=XXXXX -IPTC:ObjectName=YYYYYYY -EXIF:ImageDescription=ZZZZZZZ
/path/to/file1.jpg -XMP:Title=XXXXX -IPTC:ObjectName=YYYYYYY -EXIF:ImageDescription=ZZZZZZZ -XMP:Subject="Keyword1", "Keyword2", "Keyword3" /path/to/file2.jpg


It will write to both file1.jpg and file2.jpg. It will get ready to assign Title, ObjectName, and ImageDescription to the files, but the later assignment of these value will take precedence.  For example, if the second Title assignment was -XMP:Title=QQQQ, then QQQQ would be written to the Title of both files.  Keyword1 would be written to the Subject of both files and then you'd get an error as it looked for files named Keyword2 and Keyword3.

Quote from: ribtoks on August 23, 2017, 05:15:33 AM
1. Can it be done for several files as I wrote? Like iteratively options for each file (ending with path to that file).

As you wrote, no.  It will assign all data to both file, with later tag assignments taking precedent over previous assignments.  You need to send an -execute command to do the actual write operation to each file.

Quote2. Is that correct format in the assumption? Or maybe do I need to split -XMP:Title and XXXXX to separate lines?

They are a single argument, so you wouldn't split them.  If you don't split it on the command line, don't split it in the arg file.  For example, since you have to have a space between the -sep option and what you want to use as a separator, each part would be a separate line.

Quote3. How to write XXXXX, YYYYYY and ZZZZZZ if they are UTF-8 strings with spaces and, possibly, newlines?

For spaces, you would just place them in the appropriate spot.  From the docs, "Normal shell processing of arguments is not performed, which among other things means that arguments should not be quoted and spaces are treated as any other character."  Take note that this means that trailing spaces will be added to any tag.

I'm not completely sure about new lines, but I'd suggest trying $/ (see -printFormant) or the -E option in FAQ 21.

Quote4. How to write keywods? A keyword is a UTF-8 string with spaces. Do I need to put them into 1 line or to put each one to the separate line or what?

If you're just adding those keywords without worrying about any previous keywords, just add each one like normal:
-XMP:Subject=Keyword1
-XMP:Subject=Keyword2
-XMP:Subject=Keyword 3


Spaces, just put them in (Keyword 3 above).  Make sure you read FAQ 17 when dealing with list type tags such as this.

You can test everything out ahead of time by just creating a test -@ Argfile and using that to see the results before you jump into using -stay_open
"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

ribtoks

#2
Quote from: StarGeek on August 23, 2017, 11:45:19 PM
I've never used the -stay_open option but you'll want to take a close look at the -@ argfile docs. 

@StarGeek, thanks a lot for your time and your answer. Good catch on -execute. Missed that. I hope you don't mind 1 more small question regarding your answer:

1. Your/my keywords example (4). You wrote about adding them. I've read FAQ 17 about lists, but it says with the format you mentioned it should overwrite existing keywords to 3 keywords in the argfile, not add 3 keywords (to add you use +=). Can you confirm it was your mistake or point me to a doc where it's clearly stated? Because I'm slightly confused.

P.S. Regarding trying first, I have had problems on Windows with non-latin filepaths specified via temporary argfile. It has been discussed in the other thread. That's why I'm actively discussing stdin way of doing so since it solved my issues.



StarGeek

Quote from: ribtoks on August 24, 2017, 06:04:04 AM
1. Your/my keywords example (4). You wrote about adding them. I've read FAQ 17 about lists, but it says with the format you mentioned it should overwrite existing keywords to 3 keywords in the argfile, not add 3 keywords (to add you use +=). Can you confirm it was your mistake or point me to a doc where it's clearly stated? Because I'm slightly confused.

I'm sorry if I wasn't clear.  I was trying to say that if any previous keyword data didn't matter to you, then that was the format to use.  Yes, that format overwrites any previous data.
"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