ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: balkisanton on October 14, 2024, 11:08:59 PM

Title: Issue with Quotation Marks in PowerShell Using ExifTool
Post by: balkisanton on October 14, 2024, 11:08:59 PM
I am experiencing a problem with ExifTool when trying to use (two) quotation marks within text fields in PowerShell commands.

When I attempt to include spaces within quoted text, it results in an error stating "File not found".

For example:

.\exiftool.exe -Comment='This is a "quoted_mark" and "this is 2nd version" text' *.png
I've try this also:
.\exiftool.exe -Comment='This is a `"quoted_mark`" `"this is 2nd version`" text' *.png
This command fails if there are spaces within the quotation marks. It appears that PowerShell might be misinterpreting the space as a separator even when the text is within quotes.

Has anyone else encountered this issue? Any advice on how to correctly format the command to avoid this error would be greatly appreciated.

Thank you!
Title: Re: Issue with Quotation Marks in PowerShell Using ExifTool
Post by: StarGeek on October 15, 2024, 09:23:40 AM
Simple answer, use CMD.

PowerShell has different quoting rules than every other command line. I posted on this previously (https://exiftool.org/forum/index.php?msg=80581). I've long since given up on figuring out PS's... idiosyncrasies (the words I actually use are more colorful). If you insist on using PS, then you'll have to find a solution elsewhere, as this is a PowerShell issue, not an exiftool one.

Also, another reason not to use PS is that it corrupts binary data (https://exiftool.org/forum/index.php?msg=41663) when using a pipe | or file redirection.
Title: Re: Issue with Quotation Marks in PowerShell Using ExifTool
Post by: FrankB on October 15, 2024, 10:11:18 AM
I'm no fan of PS either, but couldn't resist playing. This works for me in PS.

-Comment='This is a \"quoted_mark\" and \"this is 2nd version\" text'
Title: Re: Issue with Quotation Marks in PowerShell Using ExifTool
Post by: balkisanton on October 16, 2024, 08:20:29 PM
Great, it's solved. Thanks for the valuable answer! 🎉