Reputation: 402
I am using FC filename1 filename2 >> myLog.txt
(where myLog.txt exists) command under Windows to compare two files. I use the command in a loop so I could compare many pairs of files.
I want to ignore the output when FC
outputs:
Comparing files filename and filename2
FC: no differences encountered
Because it floods the output file with unwanted information.
How can I do this? And if possible, can I count the number of "successfull"(the one which output I ignore) compares?
I tried with FC filename1 filename2 2> myLog.txt
to redirect only the error stream, but it doesn't output anything, meaning the command only outputs to the standard stream.
Upvotes: 0
Views: 2341
Reputation: 4750
Easy enough to do by piping output of FC to FIND /V or FINDSTR /V. Check out the help on those commands. If you have any further questions please post your code.
Upvotes: 2
Reputation: 67296
You have not specified how you "use the command in a loop so I could compare many pairs of files" (how do you get the second file of each pair in the loop?), so you must modify the code below accordingly.
@echo off
setlocal
set successfull=0
(for %%a in (filename1*.txt) do (
FC "%%a" "%%~Na2.txt" > diffs.tmp
if errorlevel 1 (
type diffs.tmp
) else (
set /A successfull+=1
)
)) > C:\other\folder\myLog.txt
del diffs.tmp
echo Successfull compares: %successfull%
If the myLog.txt
file must grow with each run of this program, then just change the >
redirection by an >>
append one...
Upvotes: 2