Comparing files in Windows

From time to time you may need to compare the content of two files for whatever reason. Opening them side by side and manually skimming them is always an option, but it’s a lengthy process and you may miss out on a few differences. For this reason, it’s best to have your computer compare files for you and present you with what it found.

Using FC

Windows includes a useful command line program called FC.exe (File Compare) that compares two files and returns a list of mismatches in their content. Its basic syntax is as follows

fc file1 file2

FC gives two more lines as a context, one before and one after the mismatching line, as shown in the example below:

FC includes a few useful options that modify its behaviour. Those that I consider most useful are the following:

Option Behaviour
/C Disregards the case of letters (case-insensitive comparison).
/N Displays the line numbers. Useful if you want to know where the differences are.
/L Compares the files as ASCII text.

Compares the files as Unicode text.

As we explained in a previous article, it’s possible to redirect the output of FC to a file using the greater than sign. For example:

fc file1 file2 > comp.txt

Will create a text file named comp.txt containing the output of the comparison.

If the two files are identical, FC will yield the following output:

FC can be very useful when comparing text files, such as those with txt or html file extensions, but it falls short when it comes to comparing more complex file formats, such as docx or xlsx files. Those will need a more advanced comparison method, as discussed below.

Using Notepad++

Notepad++ is an open source text editor that takes advantage of native Windows APIs to provide better functionality than those in regular Notepad. What’s interesting about this program is that it’s very extensible through plugins. One of those, named Compare, is very useful for this purpose. To install it, click Plugins at the top left of the menu bar, then select Plugin Manager and Show Plugin Manager. Tick the checkbox next to Compare and click Install.

To start comparing two text files simply press the keyboard combination Ctrl + D. To stop comparing, use Alt + Ctrl + D.

This plugin locks the scrolling of the two files, which is handy to not lose track of where you are in each.

Comparing Word documents

As I anticipated above, FC and the Compare plugin are useful with plain text files, but DOCX documents are a lot more complicated than those, because they include lots of additional information, such as formatting. Running FC on two Word documents is simply out of the question, because you’ll end up with lots of garbled information, as shown in this screenshot:

There are numerous applications capable of comparing Word document out there and for the most part they do an excellent job. The downside is that they’re also very expensive, but luckily Word does include a compare functionality. To enable it, click on the Review tab, then on the Compare icon.

The good thing about Word’s compare functionality is that it even supports files in different formats.

On the far right of the screen are two squares showing the two files, whereas on the left you get a list of all changes and in the middle is a combination of the two versions.

It may take some time to get used to, but when you get accustomed to the interface. You can approve or reject edits as you normally would with a “regular” Word document.

Comparing spreadsheets

I have bad news: if you need to compare spreadsheets and don’t have an Office Professional license, you’re in deep shit. Office Professional includes a small, yet very useful application called Spreadsheet Compare 2016 which does exactly what its name implies. It’s powerful and relatively easy to use, but shelving out the price Office Pro retails for just to get that application may be a bit of an overkill. Third party software that compares spreadsheet is usually expensive, too, and depending on how often you use them, getting one may not be an ideal solution, either.

There is, however, a workaround through which you can compare Excel and Open Document spreadsheets, although it has some severe drawbacks that prevents it from being applicable to all use cases. This method entails converting both spreadsheets to the CSV format by clicking on File > Save As… and selecting that format from the dialog that appears afterwards. If you know the first thing about CSV, you know that that format isn’t meant to store formulas. It’s called Comma Separated Values, after all. Thus, you should be aware that whenever you save as CSV, your formulas are automatically converted into values and you lose all formatting information, as well as graphs and macros. If you need to compare those, look elsewhere.

Note: The workaround detailed here will only work if you exported the two files from the XLS or XLSX formats, but not if you edited the CSV files by hand. You should also be aware that you will need to export each sheet individually.

Comparing values in spreadsheets using FC

Since CSV files are nothing more than regular text files, they can be compared using the FC command. After having saved the two spreadsheets as CSV (for the sake of simplicity, we’re assuming you saved both in the same folder with different names), open a Command Prompt shell and type (case doesn’t matter)

CD C:\Path\to\the\files
FC /N file1.csv file2.csv

You will get a result similar to this:

In this example, the third line contains different entries.

Comparing formulas using FC

This method is a twist on that described in the previous paragraph. Most steps are identical, but with a key difference: before saving as CSV, we’re using the Find & Select button from the Home tab. Select Replace and use the following settings in the dialog that appears.

What we’re trying to do is replacing all occurrences of the equal sign with nothing. You already know that every formula in Excel is preceded by an equal sign, so we’re converting formulas to actual text. Repeat the exact process for the other spreadsheet and save both as CSV.

We can then run the same commands as above and we would get a result akin to this:

About Andrea Luciano Damico 137 Articles
Andrea Luciano Damico is a freelance translator from Italy. Among his interests are linguistics, technology, video games, and generally being a chill guy. He runs Let's and