Welcome to Atlanta .NET Regular Guys Sign in | Join | Help

Free file comparison utility you ALREADY have

I was watching Brendon work on a web page last night in a virtual PC, which brought me back to the times that I spent working in virtual machines. I don't have to do that any more as I'm currently only working on one version of a product at a time, but that's another story. This story is about how I used to get annoyed by some of the little problems involved with working in a virtual environment. For one thing, all the cool little programs you have on your desktop are missing. When you work in source code a bunch, one of the more valuable tools (at least in the environment I used to be in) is a file comparison tool. Nothing big, just something to get the job done. Well, I was wandering around in my memory, that lead me to the web, and two short clicks later I was looking at documentation for a built in XP comparison tool that I never knew existed.

People making a question mark

Comp
Comp is not a complex tool. It's completely command-line based (my posting command line tips and tricks seems like an occasional theme around here) and already installed with Windows XP.  I actually learned about it here - on the ComputerHope.com site

Let's say I have 2 files that I want to compare:

It was
the best
of times,
it was the
worst of
times
It was
the bet
of time,
it was the
worst of
time

This is of course a completely trivial example, but what I'm driving at will hopefully become clear.


Anyway - I've made some deliberate misspellings in the document on the right.  I'm missing 2 's's.  If this was a large XML document, that might be hard to spot.  This might be where I'd turn to my handy COMP utility

C:\temp>comp /?
Compares the contents of two files or sets of files.

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]

data1      Specifies location and name(s) of first file(s) to compare.
data2      Specifies location and name(s) of second files to compare.
/D         Displays differences in decimal format.
/A         Displays differences in ASCII characters.
/L         Displays line numbers for differences.
/N=number  Compares only the first specified number of lines in each file.
/C         Disregards case of ASCII letters when comparing files.
/OFF[LINE] Do not skip files with offline attribute set.

To compare sets of files, use wildcards in data1 and data2 parameters.

C:\temp>

It is important to note that the /N option is required to actually see the differences.  Otherwise you'll just get whether or not the file sizes are different

C:\temp>comp test1.txt test2.txt /N=10 /A
Comparing test1.txt and test2.txt...
Compare error at LINE 2
file1 = s
file2 = t
Compare error at LINE 2
file1 = t
file2 =
Compare error at LINE 2
file1 =
file2 =

Compare error at LINE 3
file1 =

file2 = o
Compare error at LINE 3
file1 = o
file2 = f
Compare error at LINE 3
file1 = f
file2 =
Compare error at LINE 3
file1 =
file2 = t
Compare error at LINE 3
file1 = t
file2 = i
Compare error at LINE 3
file1 = i
file2 = m
Compare error at LINE 3
file1 = m
file2 = e
10 mismatches - ending compare

Compare more files (Y/N) ? n

C:\temp>

This is nothing spectacular, other than it finds screw-ups and points you at the line numbers and whatnot.  I can't say that this will replace anyone's favorite comparison tool like Araxis Merge or BeyondCompare but this might prevent you from mucking up your otherwise "clean" virtual machines.

The real moral of this story is that there are tons of available commands listed in the Windows XP Pro Command Reference and you should at least glance at it now and then.

Published 11-04-2006 08:29 by Matt Ranlett
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

What do you think?

(required) 
(optional)
(required) 

About Matt Ranlett

One of the two original Atlanta .NET Regular Guys, Matt fills his free time by helping to run several Atlanta area user groups, the Atlanta Code Camps, and works as one of the two INETA co-Vice Presidents of Technology
SkinName:iroha_Blog2
Powered by Community Server, by Telligent Systems