How To Make Sure The Files You Copied are the Same as Original


Let’s say you have a large chunk of files you want to copy to another location for archiving. Since the data will be in the archiver for years the last thing you need is to find out the data you copied years ago are not the same copy as you wished. So, how do you know the integrity of the data is kept the same during the copy procedure?

One reliable way to make sure the data in the source and destination location are the same is to use the hash file. Generate a hash for each file in the source and compare with the one generated in the destination. If both are the same, you know the integrity of data on both ends.

But that sounds a lot of extra work involved, though there are ways to generate hash files in Windows.

Is there any easier way?

The latest PowerShell version introduced a set of cmdlets that let you generate a catalog file containing a full list of hash files for a given folder and use it to compare that same folder to verify that what was in the source folder is also at the new location.

Here is how to do it.

First, use New-FileCatalog cmdlet to generate a catalog file of a source folder.

New-FileCatalog -Path source -CatalogFilePath -CatalogVersion 2.0

Then, copy the source folder to the destination, using any file copy tools, i.e. RoboCopy.

Once copied, use Test-FileCatalog cmdlet to verify the destination using the catalog file generated earlier.

Test-FileCatalog -Path destination -CatalogFilePath

Take close look at the output, what you expect to see is the Valid output in Status field. If failed, you better go one step back and re-copy the data over.

image 6 600x123 - How To Make Sure The Files You Copied are the Same as Original

Since both New-FileCatalog and Test-FileCatalog cmdlets only work in PowerShell 5.1 and later, if you are on Windows 7 or 8.1, follow the instruction to upgrade your PowerShell to the latest version.


Please enter your comment!
Please enter your name here