Solved

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

Posted on 2010-11-10
7
491 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 84

Accepted Solution

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

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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 
LVL 54

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 69

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…

730 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