Author Topic: Syntax questions " ", $, % Warning: several simple syntax questions.  (Read 538 times)

tommyzebman

  • Jr. Member
  • **
  • Posts: 24
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16698
    • ExifTool Home Page
Re: Syntax questions " ", $, % Warning: several simple syntax questions.
« Reply #1 on: February 19, 2019, 12:48:34 PM »
Hi Tommy,

Quote
However 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.

Quote
When is $ needed in front of a tag name?

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

Quote
If 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.

Quote
Can 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3791
Re: Syntax questions " ", $, % Warning: several simple syntax questions.
« Reply #2 on: February 19, 2019, 01:10:11 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"
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

tommyzebman

  • Jr. Member
  • **
  • Posts: 24
Re: Syntax questions " ", $, % Warning: several simple syntax questions.
« Reply #3 on: February 19, 2019, 02:47:23 PM »
Thanks to all.  It seems I am on my way now to using Exiftool more intelligently.