problem escaping in exiftool using exec() macro command on Windows
Posted by
Bill Christens-Barry-2 on
URL: http://imagej.273.s1.nabble.com/problem-escaping-in-exiftool-using-exec-macro-command-on-Windows-tp5023850.html
Using ImageJ 1.53c and earlier, I'd like to be able to use the exec() command and exiftool on a Windows 10 machine to assign the contents of a text file to a particular metadata tag (Image Description) of an image.
On macOS using exiftool the following macro command works fine using backslash escaping of the arguments to exiftool (warning: this line may have been broken into two lines in this posting):
exec("bash", "-c", "/usr/local/bin/exiftool \"-ImageDescription<=/Volumes/USBstick1/ExampleText.txt\" /Volumes/USBstick1/ExampleImage.tif");
On a macOS machine this correctly writes the text in the file "ExampleText.txt" file into the Image Description metadata tag in the header of "ExampleImage.tif". Exiftool documentation notes that for this operation the "<" character needs to be escaped, as is done here using backslash quote escaping. It's also OK to use "ImageDescription" without a space in the exiftool command.
On Windows I've not been able to make this work. The problem seems to be determining how to escape the special character "<" in the arguments to exiftool. After much searching and many attempts to escape via the usual escape suspects (`, \, ^, etc.) I haven't yet solved this.
The syntax of the call to exiftool itself, i.e.:
exec("cmd", "/c", "C:Windows/exiftool.exe", "xxxx xxxx");
is successful, as using a similar construct to read the ImageDescription tag works. However, the details of escaping the arguments to exiftool (shown as "xxxx xxxx" here) that must be done to write that tag due to the "<" character seems to be the problem.
Does anyone have suggestions or an example of how this can be done?
Thanks.
Bill
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html