Solved

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

Posted on 2010-11-10
7
472 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
7 Comments
 
LVL 83

Accepted Solution

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

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 53

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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