How to get ERRORLEVEL for each command in FOR LOOP?

Viewed 1777

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?

1 Answers
Related