I'm trying to find differences in the content of two folder structures using Windows Powershell. I have used the following method to ensure that the file names are the same, but this method does not tell me if the contents of the files are the same:
$firstFolder = Get-ChildItem -Recurse folder1
$secondFolder = Get-ChildItem -Recurse folder2
Compare-Object -ReferenceObject $firstFolder -DifferenceObject $secondFolder
The technique described in this ServerFault question works for diffing a single file, but these folders contain hundreds of files at a variety of depths.
The solution does not necessarily need to tell me what specifically in the files is different – just that they are. I am not interested in differences in metadata such as date, which I already know to be different.
Best Answer
If you want to wrap the compare into a loop I would take the following approach:
Note that this will ignore files which do not exist in both
$folder1
and$folder2
.