?
Solved

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

Posted on 2010-11-10
7
Medium Priority
?
514 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 500 total points
ID: 34107475
That program already comes with any Windows version:
fc.exe <file1> <file2>
0
 
LVL 97

Expert Comment

by:Experienced Member
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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 56

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 500 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 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