How to compare files

If you're a writer or a programmer, you probably have multiple working versions of your documents. Comparing these files allows you to track changes and merge the differences between two versions of the same file.

Also, copying files can sometimes lead to data loss, requiring you to do comparisons and make sure nothing has been corrupted.

File comparison is possible in editing source code editors, Microsoft Office tools and even between two file directories. You can usually compare files from Windows, Mac, and Linux operating systems in several ways. We will guide you to the most effective and practical solutions.

How to compare files in Notepad++

If you write code every day, you've probably had occasion to use Notepad++. It is a text and source code editor compatible with the Windows operating system.

It is completely free software that does not even require much storage. Many programmers use Notepad++ to compare two files, but this feature is not built into the editor by default.

Luckily, all you have to do is install the “Compare” plugin. Here are all the steps you need to follow to compare two files in Notepad++.

  1. Download and install Notepad++ on your Windows computer.
  2. Launch Notepad++ and click on the “Plugins” option in the main toolbar at the top.
  3. From the drop-down menu, choose "Plug-in Administrator".
  4. In the list of plugins, check the “Compare” option then click on the “Install” button.
  5. Open two files at the same time and then navigate to the "Plugins Admin" option again.
  6. From the drop-down menu, select "Compare".

Notepad++ will immediately display any difference between the two files.

Any line of code added, deleted or changed in any way will be highlighted in Notepad++. These differences will be color-coordinated so that users can track them more efficiently.

How to Compare Files in Visual Studio Code

Another popular source code editor used by many developers is Visual Studio Code. It is available on Windows, macOS and Linux.

It supports countless programming languages ​​and lets you edit, create, and debug code. But you can also use it to compare two files and find differences. This is how it works:

  1. If you haven't already, download and install Visual Studio Code on your computer.
  2. Launch the editor and open the files you need to compare.
  3. Select them both and use the Shift key on your keyboard.
  4. Right-click the files and select "Compare Selected" from the menu.

It's a way to compare files in Visual Studio Code. But here's another way to do it:

  1. Right click on the first file.
  2. Click "Select to Compare" in the menu.
  3. Right click on the second file.
  4. Click on “Compare with selection.” 

Both options are quick, simple, and deliver the same results.

How to compare files in two folders

For some projects you will need to compare the contents of two folders and even subfolders and not just two files. Doing it manually would be incredibly time-consuming and tedious work.

Fortunately, there are shortcuts you can take. If you are a Windows user, your best option is probably the WinMerge utility tool. It's completely secure and free, and here's how you can use it:

  1. Download and install WinMerge on your Windows computer.
  2. Once the installation is complete, press the CTRL + O key on your keyboard. This will open the Compare Folder window.
  3. Click "Browse" to select the first folder and follow the same step for the second folder.
  4. Be sure to check the "Read-only" box next to both folders.
  5. Now click on the “Compare” button.

The comparison process starts immediately. If the size of the folders is relatively small, you won't have to wait too long. However, if the directories you are comparing are quite large, you will need to be patient.

WinMerge will show unique files in white and files with no similarities in yellow. Overlapping files will be categorized in gray. You can view these differences by right-clicking on the files.

Mac users can rely on Terminal to compare two folders. It is a command-line tool used by developers to make quick and easy changes to the operating system. Here's how you can use it:

  1. Go to “Applications” then “Utilities”.
  2. Use the "cd" command to navigate to the directory containing the folders you want to compare.
  3. When you are there, run the following command “diff -rq folder1 folder2”.

That's all you need to do. You will be able to see the line-by-line differences in the text and code.

How to Compare Two Excel Files

Comparing two Excel files can be useful when dealing with a small set of data. You can use the built-in compare tool and review the files manually.

For example, let's say you have two Excel stock tracking files from two different months and you need to check their values. Here's how to create a handy preview for easier comparison:

  1. Launch Excel and open the two files you want to compare.
  2. Be sure to select the sheet in each file that will be compared.
  3. Go to the "View" tab in the main toolbar.
  4. In the "Windows" section, select the "View side by side" option.
  5. Excel will automatically arrange the workbook horizontally and both files will be visible.

You can now compare and edit these files manually.

However, you can also rely on a third-party online comparison tool in a pinch. Check out the XL Comparator tool if you don't want to waste your time and need a quick comparison report.

It is a free resource that supports Excel files up to 5MB in size. All you have to do is upload two files and configure the comparator to find matching or different data. You can download the results and compare the similarities or differences highlighted.

While this method can be useful and lightning-fast, it's probably not the best strategy if you're dealing with sensitive data.

How to Compare Two Word Files

If writing is something you do every day, comparing previous and current versions of Word documents to text files can be essential.

Sometimes you need to merge two documents, but first you need to consider if there is any overlapping or repetitive information.

Fortunately, as a Microsoft word processor, Word has a built-in feature that can help you compare two versions of a document.

Follow the steps to compare two versions of a document in Word:

  1. Open any version of the document in Word.
  2. In the "Reviews" tab, navigate to the "Compare" ribbon.
  3. From the drop-down menu, select the “Compare…” option.
  4. A new window will open. Download both versions of the document and click "OK".

If changes were tracked in the revised document, the panel on the left side lists all revisions.

On the right side you will see the original file stacked on top of the revised file. As you scroll through the text, they move simultaneously and allow you to examine the differences.

You can also access the "Combine" function in the "Compare" ribbon. It allows users to combine revised Word documents from multiple authors.

How to Compare Files in Linux

Writers and programmers who prefer to use Linux also benefit from comparing two files to examine the differences.

There are several ways to compare files in Linux, including using the Visual Studio code editor. However, one of the oldest and most popular ways to compare text and code is to use the "diff" command.

This command-line tool is easy to use and comes pre-installed on most Linux systems. Here's what that command line syntax looks like:

« diff [options] File1 File2« 

In Linux, you can also use Kompare, a graphical user interface, to see the differences between two files.

How to Compare Files in Windows 10 Command Prompt

Windows users have the option of relying on the operating system's built-in command-line tool to compare two files. It's a simple process if you know exactly what to do.

However, for this to work correctly, the files must be in the same location. Make sure they are in the same folder and follow these steps to compare them:

  1. Go to "Start" and search for "Command Prompt".
  2. Select the "Run as administrator" option.
  3. Copy and paste the following command “cd PATHTOFILES” and press “Enter”.
  4. Update the command with the location of the files.
  5. Now enter the following command – “fc filename1.txt filename2.txt” – and press “Enter”.

Make sure to write the correct filename instead of "filename1" and "filename2".

Manage your files successfully

Even if you don't code or write every day, you may need to compare existing files from time to time. The good news is that there are plenty of great tools that can help you do this. Text and code editors such as Notepad++ and Visual Studio Code are great tools that provide immediate results.

Plus, everything is color-coordinated for a better user experience. Microsoft tools such as Excel and Word have built-in comparison tools, but they have limitations. You get a better overview, but you still have to observe the differences for yourself.

To compare two folders, you'll need a third-party tool on Windows or a working knowledge of Terminal on macOS. Finally, Linux offers several solutions, and on Windows you can always launch a command prompt to compare two files.

What would be your favorite way to compare two files? Let us know in the comments section below.

Audio Video How to compare files
add a comment of How to compare files
Comment sent successfully! We will review it in the next few hours.