Terms of Use For FixedByVonnie

By proceeding to access fixedByVonnie.com, you expressly acknowledge, and agree to, all of the following:

fixedByVonnie.com is a personal website and blog owned by Security Plus Pro LLC, which is being presented for informational purposes only. The views on this website are solely those of the website owner (and not those of any employer or of any professional associations affiliated with the website owner).  Any views expressed in this website and any information presented on this website, or in any of its blog entries, should not be relied on for any purpose whatsoever other than as the personal opinions of the website owner.  The website owner expressly disclaims any and all liability for any information presented on this site.  The owner of this website and its blog posts shall not be held liable, and shall be held harmless, for any errors or omissions in any information or representations contained in this website, or in any of its blog entries.  The website owner also expressly disclaims any liability for the current or future availability of any such information. The website owner makes no representations as to the accuracy or completeness of any information on this website or which may be found by following any link on this website. The website owner shall not be held liable for any losses, injuries, damages, claims, or causes of action, from the display or use of any information on this website or in any of its blog entries. If you use the information on this website, or on any of its blog entries, you do so solely at your own risk.

Fun with File Compare - fixedByVonnie

Fun with File Compare

Did you know Windows has a built in file comparison tool?

There are a few things you can do to compare files and analyze differences.  If you need visual differences of merged files, version control and folder comparisons then Winmerge is a great tool for the job.  It’s fast, free and fabulous and I highly suggest it for bigger projects.  I’ve used Winmerge many times while perusing logs and it really helped me discern subtle differences.

But sometimes you don’t need all the functionality that comes with Winmerge.  That’s where FC.exe can save your butt.

Let’s get this show started.

First we need to open an Elevated Command Prompt.


Change to the directory that contains the files you need to compare and then type:

fc filename1.txt filename2.txt

In the graphic below you can see I’m trying to compare two text files:

One is called gangnam-style.txt and the other is gangnam-style-dupe.txt.

In this case, both my files are identical so FC plainly says no differences encountered.


But this is pretty boring right?

Let’s see what happens when we introduce a change.

I replaced the first word “Hey” with “Yo” and saved the changes.

Comparing different file lines

As expected, file compare notices the difference and prints the affected line.  The file boundaries are marked off by asterisks and the output is generally easy to read.

But did you see something else here?  File compare also printed the line after the line we changed.  We don’t care about that line so we should trim the output.

You can set the number of lines to print, the line buffer, by appending the fc command with /lb (that’s a lowercase “L”) and the number of lines you want.  This is good for large files that might give you too many matches.

For example, since I only want to view a single line of matches I typed this before my filenames:

fc /lb1

Using the /lb switch with fc.exe

To include line numbers, just add the /n parameter.  Noticed I tacked that on to the previous /lb1 switch.

You can stack up options like this to create a Frankensteinian output that perfectly suits your diabolical plans.

fc.exe with line numbers using /n

Let’s see what else can do here.  In the screenshot below, I added the line “Okay maybe not” to the second file and fc.exe happily displayed the result.

Using fc.exe to compare different files

If you need to do a comparison that ignores case use the /c switch.

In the image below you can see two files with identical content.  The only difference is that one is all lowercase and the other is all uppercase.

If I try to compare these without the /c switch, fc.exe barks at me.  It thinks the files are different because the ASCII codes that represent upper and lowercase characters are different.

It’s only when I added the /c parameter that fc.exe became a cold, dispassionate, completely case insensitive command.


Using fc.exe to compare while ignoring case

You can even use fc.exe to do a byte-by-byte comparison of two files.  .exe and .bin files default to byte comparison mode but if you want to force it on different file types just use the /b command option.

For example, I changed “Hey” to “Hay” in the second file and ran a byte-to-byte comparison.

You can see from the properties of each file that gangnam-style-dupe.txt is two bytes longer and that result is reflected in the command prompt output in the right.

Doing a byte-by-byte comparison with fc.exe

You can see a full list of fc parameters on Technet or by typing

 fc /?

The Bottom Line

FC can’t do everything.  It’s just a itty bitty program that does a simply ASCII or binary comparison.  But sometimes that’s all you need right?  What do you use for your text comparisons?


Connect with Vonnie on Twitter

Posted in Windows, Windows 10, Windows 8, Windows 8.1 Tagged with: , ,
  • Good