Folder Content Comparison

Folder A and B contains some text files,some are identical. I used get-childitem and compare object with the basis of Name and Hash to compare the contents.Now my output contains both files which are different with hash value as well as file missing in folder B in comparison to folder A.
How can I print only the file names which only are different from folder A to folder B excluding the missing files.

That depends pretty much on the code you used to do the comparison. :wink:

Your code is broken. What IDE do you use?

Sorry,will share code shortly

$PostFileshash = (get-childitem D:\Users\test\Post | foreach (Get-FileHash -Path $.FullName))
$PreFileshash = (get-childitem D:\Users\test\Pre | foreach (Get-FileHash -Path $.FullName))


$AllHash = (Compare-Object $PreFileshash $PostFilesHash -Property Name, hash -PassThru ).path 

$MissFile = split-path(Compare-object $PreFileshash $PostFileshash -Property Name -PassThru).path -Leaf

if($MissFile -eq $null) {$MissFile = Write-Output "No Missing Files"}

if($AllHash -eq $null) {$AllHash = Write-Output "NoChange in Files"}

Write-Output "The Following files have Different Hash: $AllHash"

Write-Output "Missing PostFiles: $MissFile"

Your code is still invalid. Don’t you get error messages when you run this code? :thinking:

Yes,It is running without any issues

That’s impossible. You’re lying.

These two lines of code cannot run this way.

Whoopsies,replace this with an older code

$PostFileshash = (get-childitem D:\Users\test\Post | foreach (Get-FileHash -Path $_.FullName))
$PreFileshash = (get-childitem D:\Users\test\Pre | foreach (Get-FileHash -Path $_.FullName))

I don’t like anymore. I’m out.

Good luck.

Sorry for the Ruckus.
I only want to know the logic of how to get the desired File Content