ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Rob Galbraith on December 23, 2013, 10:08:18 AM

Title: Alternative to single quotes for EXIFTool IPTC writing on Mac
Post by: Rob Galbraith on December 23, 2013, 10:08:18 AM
Hi,

I'm using EXIFTool 9.36 on a Mac OS X 10.8.5 system to write caption data to JPEGs. An AppleScript is reading a paragraph from a text file and then EXIFTool (within the same AppleScript) is being used to write that paragraph into the IPTC caption field.

Things works perfectly as long as the paragraph of text does NOT contain a single quote character, i.e. Fred's. The presence of the single quote in the text causes the caption to be truncated at that point. I quickly figured out why: EXIFTool on the Mac relies on the single quote character to surround the text to be written.

My first workaround attempt was to use AppleScript to change all single quotes to smart single quotes before handing off the text to EXIFTool, and this solved the problem but created another. The smart single quote character doesn't display properly in some metadata viewers.

So, I'm stumped and would appreciate any suggestions as to how to get around this problem. Note that using double quotes won't do the trick, in that some captions will inevitably contain double quotes in addition to single quotes.

Thanks for your time. And thanks Phil for creating such a useful tool!

The relevant snippet of AppleScript is below. The variable theCaption contains the to-be-written text pulled from a plain-text text file.

set theCaption to "-Caption-Abstract='" & theCaption & "' -overwrite_original"
set theFile to item i of fileList
set exiftool_args to theCaption
set exiftool_args to exiftool_args & " " & quote & POSIX path of theFile & quote
do shell script exiftool_path & "exiftool " & exiftool_args


-Rob Galbraith
Title: Re: Alternative to single quotes for EXIFTool IPTC writing on Mac
Post by: Phil Harvey on December 23, 2013, 05:19:29 PM
Hi Rob,

I recall that the AppleScript incantation to do what you want is "quoted form of" ...

I think that googling this may turn up some examples for you.

- Phil
Title: Re: Alternative to single quotes for EXIFTool IPTC writing on Mac
Post by: Rob Galbraith on December 23, 2013, 05:41:56 PM
Hi Phil,

Thanks very much, I will look into that.

-Rob Galbraith