Command format. What does $ do?

Started by EvilUnicorn, November 18, 2022, 11:10:00 AM

Previous topic - Next topic

EvilUnicorn

I'm testing the following command but see no difference in output. Should or shouldn't I use $?

exiftool -d '%Y%m%d_%H%M%%-c.%%e' '-filename<$CreateDate' P1001935.jpg
exiftool -d '%Y%m%d_%H%M%%-c.%%e' '-filename<CreateDate' P1001935.jpg

Both have the same output: 20210923_1527.jpg so what is the correct format?

StarGeek

Quote from: EvilUnicorn on November 18, 2022, 11:10:00 AMShould or shouldn't I use $?

Yes...

Oh, you want more ;)

This would be Common Mistake #5b.  When you using just a tag and are not mixing tag and static string, then technically you would not include the dollar sign.  But the difference is going to be so slight that you won't even notice it.

In the case of list type tags such as Keywords or Subject, there are other things to worry about, as the dollar sign changes a list into a string and would require the -sep option to turn it back into a list.
* 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).

Phil Harvey

Quote from: StarGeek on November 18, 2022, 11:19:30 AMIn the case of list type tags such as Keywords or Subject, there are other things to worry about, as the dollar sign changes a list into a string and would require the -sep option to turn it back into a list.

Good point.  I should add this to the above mentioned documentation.

- Phil

Edit:  Oh.  It's already there. :P
...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 ($).