I am comparing a list of files from 2 folders using a windows batch file. It prints the results whether PASS/FAIL.
Current Working Batch File:
for /F "tokens=*" %%f in (list.txt) do compare Folder1\%%f.png Folder2\%%f.png
If there are 3 files, the output after running this command would look like this:
PASS
FAIL
PASS
If I echo the %ERRORLEVEL% here, it would return 0 because the for loop ran fine.
echo %ERRORLEVEL%
0
My Requirement
Echo the result of each command in the FOR loop instead.
My Expected Output
0
1
0
How do I change the batch file to achieve this?
Assuming that FAIL changes the
ERRORLEVEL
, Use&
to echoERRORLEVEL
for each command:OUTPUT:
I assume PASS/FAIL is the output of your
compare
utility. To hide this output use redirection>
toNUL
like this:OUTPUT:
From documentation: