I am trying to generate an xml file. I compare two images using a command which returns a number. But when I try to redirect its output to a file, it prints the number with a newline character.
echo a.jpg >> "result.txt"
compare -metric NCC "a.jpg" "b.jpg" "c.jpg" 2>> "result.txt"
Expected output like:
a.jpg 1
But it outputs:
a.jpg
1
I tried to get the result from the command and tried to concatenate with the a.jpg but I couldn't have managed.
for /f "tokens=1 delims=" %%a in ('compare -metric NCC "a.jpg" "b.jpg" "c.jpg"') do set result=%%a
echo %result%
REM outputs 1ECHO is off.
now I know, what happens:
your desired output is on STDERR, not on STDOUT (very unusual). But
for
captures STDOUT only.It should be possible do adapt the
for
construct, but it's simpler to use: