Solved

How to compare two or more files in windows batch file and display differences?

Posted on 2010-11-10
7
503 Views
Last Modified: 2012-05-10
Hi,

I am trying to write a windows batch file that will compare two files and display the difference.  Say a two files in drive C:\.


Regards
Sandy
0
Comment
Question by:sweetiepie70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 125 total points
ID: 34107475
That program already comes with any Windows version:
fc.exe <file1> <file2>
0
 
LVL 95

Expert Comment

by:John Hurst
ID: 34107493
Look up Winmerge. This is a free (www.winmerge.org) utililty that is very good for file comparisons. It supports command line mode which can then be used in a batch file. See here:

http://winmerge.org/docs/manual/CommandLine.html

... Thinkpads_User
0
 

Author Comment

by:sweetiepie70
ID: 34107684
I would like to write a batch script from scratch as a .txt file and then saved as a .bat file to run in windows command prompt.  A batch file scripting should give me that result.
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 55

Expert Comment

by:Bill Prew
ID: 34108619
As mentioned earlier, you can use either FC or COMP which come built in.

~bp
0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 125 total points
ID: 34146199
Using fc for file compares in a batch script...


@echo off
setlocal

set Files_1=c:\dir1\*.txt
set Files_2=c:\dir2\*.txt

(fc %FILES_1% %FILES_2% /l) || goto DIFFERENT

echo Files sind gleich
goto END

:DIFFERENT
echo Files sind ungleich

:END

endlocal

Open in new window

0
 
LVL 70

Expert Comment

by:Qlemo
ID: 34375976
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question