Login  Register

Re: SOLVED: problem escaping in exiftool using exec() macro command on Windows

Posted by Bill Christens-Barry-2 on Aug 15, 2020; 5:32pm
URL: http://imagej.273.s1.nabble.com/Re-SOLVED-problem-escaping-in-exiftool-using-exec-macro-command-on-Windows-tp5023853.html

Hi again Gabriel,

I went back and retried a few things and found a solution; it involved using

   \"

to enclose the substring

  <=

to wit:

  exec("cmd", "/c", "C/Windows/exiftool.exe -ImageDescription\"<=\"C:/USBstick1/ExampleText.txt C:/USBstick1/ExampleImage.tif");

I'm pretty sure was this one of the most obvious and early things I tried (late on a Friday night), so either I misremember or it must have had a typo.

Exiftool tag writing only returns text describing its success or failure at modifying the target image file, so I tried following up with reading the new tag value via:

  exec("cmd", "/c", "C/Windows/exiftool.exe -ImageDescription\"<=\"C:/USBstick1/ExampleText.txt C:/USBstick1/ExampleImage.tif");

I can invoke exiftool independently and see that the tag value has been written anew. But, oddly, I can't yet print the returned value to the Log window in ImageJ, even though the macro language doc indicates that the result of the exec() command is returned. This is also true if I explicitly assign the result returned from exec() to a string variable (e.g. str = exec(...)). I'm not sure why the success or failure result of writing the tag is printed to the ImageJ Log window, while the result returned upon reading that tag is not and is not assigned to a variable.

Bill

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html