Skip to main content

How To Check If Two Files Are Identical

Whether you work as a programmer In a busy corporate environment, or just an average user on the PC, sometimes you may have the need to check If two files contain the exact same content. Stating the obvious, you can simply open each one and physically have a look, but If the files are heavily populated, It can be a very time-consuming process. As such, In this tutorial, I will show you how to check If two files are Identical without opening them.

For the purpose of this tutorial and to keep things simple, I will be using a couple of text files throughout the entire article. There are countless reasons why you'd want to compare and verify any differences between a couple of files. Perhaps you've added a line of code In one file, and don't remember If you did the same In the other. Or you want to forward an exact copy to your boss at work, hence want to make sure It matches with that of your own.

Whatever the reason may be, I will show you how It's done, by using the native Windows utility named PowerShell. It Is very accurate with It's comparison- to the point of detecting a difference even when a single comma has been added to a file containing tens of thousands of paragraphs! The process Is extremely simple, so without further delay, let's get this tutorial started.

Step One:

Before I begin, I have two text files (as shown below), that I'll be checking to see If they contain Identical content. They're quite large, thus manually sifting through each one, Is certainly not practical.

Step Two:

Okay, the first thing we need to do, Is access PowerShell. Open the Search bar, enter powershell and click on the search result at the top as shown below.

Step Three:

Next, enter the following command Into PowerShell, replacing C with your drive letter, and Your File Name with the name of both text files that you wish to check.
if((Get-FileHash "C:\Your File Name.txt").hash -eq (Get-FileHash "C:\Your File Name.txt").hash) {"Both Files Are Identical"} else {"Both Files Are NOT Identical"}

In my case, the command Is as follows.
if((Get-FileHash "F:\Windows10Tips1.txt").hash -eq (Get-FileHash "F:\Windows10Tips2.txt").hash) {"Both Files Are Identical"} else {"Both Files Are NOT Identical"}

Your PowerShell window, should look similar to mine. When done, hit Enter on your keyboard.

Step Four:

As you can see, a message of Both Files Are Identical has been returned. Essentially, my files are an exact copy of each other.

Last Step:

Let's test It's accuracy. I've added a single full stop In one of the files, and did not touch any other content. As expected, the difference was detected, confirmed by the message of Both Files Are Not Identical.

Final Thoughts:

I'd say It's safe to assume, that you're quite Impressed with It's accuracy In detecting every minute change In a given file. There are many third-party tools that do a similar job, but there's no need to download anything- namely for the fact that the same result can be achieved natively within Windows.


Popular posts from this blog

How To Decode The Windows 10 Product Key

Every Windows 10 operating system that's Installed and activated on the computer, has what's called a Product Key , that Is either pre-Installed by the manufacturer, or added by the end user when formatting their PC. In order to have a fully-functional OS, It must contain a valid Product Key. Whilst there are many tools that can extract It from the operating system, In this tutorial, I will show you how to manually decode the Product Key.

How To Check Faulty Drivers In Windows 10

For hardware devices to function properly, they must have device drivers  Installed, thus allow them to perform at their optimal state. It's all well and good when they're running without error, but they do tend to fail at the best of times, which can cause system Instability and/or loss of functionality. It can be a difficult task pinpointing the problematic driver(s), so In this tutorial, I will show you how to check faulty drivers , without the aid of third-party tools.

How To Create A Fake File Of Any File Size

Depending on your business environment or Individual requirements, sometimes there Is the need to test files of a given capacity. Such tests can Include Identifying how well your hard disks perform under heavy read/write operations, or to establish whether files can be securely deleted beyond recovery. Whatever the reason may be, In this tutorial, I will show you how to create a fake file of any file size.