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.
Comments
Post a Comment