Syntax questions " ", $, % Warning: several simple syntax questions.

Started by tommyzebman, February 19, 2019, 12:41:45 PM

Previous topic - Next topic

tommyzebman

I am confused when these are needed and when not.  I get the basic notion of = used to insert new data in metadata tag field VS. < which copies data from one tag field to another.

However for example given:    -artist=me  or -artist="Phil Harvey"  WHEN IS " " NEEDED ?   When is $ needed in front of a tag name?

This example was given which does work:  "-copyright<$datetimeoriginal Bill Jones"   When is $ needed in front of a tag name?  This is copying data from one tag to another but also adding new text.  Why " " around the entire expression in this case ?  If I attempt to add another text phrase in front of  $datetimeoriginal such "-copyright<Copyright - $datetimeoriginal Bill Jones"  it is REJECTED by exiftool.  I do not see any clear explanation, other than going through dozens of examples, of the various syntax rules.  Can a tag be inserted in the middle of text and then use = instead ?

I am sure there is a simple, logical answer for those that know.

Thanks.

Phil Harvey

Hi Tommy,

QuoteHowever for example given:    -artist=me  or -artist="Phil Harvey"  WHEN IS " " NEEDED ?

On Windows, you need quotes around an argument if it contains a space (and maybe other special characters, like maybe a semicolon.  You would have to read up about your terminal app for details).  If inside a .bat file, all % characters need to be doubled.

QuoteWhen is $ needed in front of a tag name?

Only when embedding a tag value inside a string, or when using an advanced formatting expression.

QuoteIf I attempt to add another text phrase in front of  $datetimeoriginal such "-copyright<Copyright - $datetimeoriginal Bill Jones"  it is REJECTED by exiftool.

This should work.

QuoteCan a tag be inserted in the middle of text and then use = instead ?

No.  See common mistake 5c.

- 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

Quote from: Phil Harvey on February 19, 2019, 12:48:34 PM
On Windows, you need quotes around an argument if it contains a space (and maybe other special characters, like maybe a semicolon.  You would have to read up about your terminal app for details).  If inside a .bat file, all % characters need to be doubled.

Other characters include the caret ^, ampersand &, pipe |, and greater/less than signs.  The caret is an escape character and will be dropped to escape the next character if not enclosed by quotes.  The ampersand will allow multiple commands on the same line to be run in sequence if not enclosed.  And the pipe character will pipe, of course.  Greater/less than signs cause file redirection, but that's pretty much already covered by the docs.

To include double quotes, I believe you need three quotes.  So to include "Quoted" text, it would be something like -Description=""""Quoted""" text"
* 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).

tommyzebman

Thanks to all.  It seems I am on my way now to using Exiftool more intelligently.