Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Compare contents of files within subfolders - output file name with folder path

$
0
0

Hi, my first delve into comparing multiple files has left me a little stuck.

Scenario:

I have two folders on different partitions, one is an old backup copy of the other.

I need to be able to provide the root folder of both locations, have a script read the files within the subfolders of location A, look for the files with extension '.z' and compare the contents of the file with the same file in the subfolder of location B.

I would then need the output for each file that is different, provide me with the file location and file name.

something like D:\Folder\subfolderB\file.x =>

C:\Folder        -     D:\Folder

subfolder A     -      Subfolder A

file.x              -       File.x

file.y              -       File.y           

file.z              -       File.z      **compare these two

subfolder B     -      Subfolder B

file.x              -       File.x

file.y              -       File.y

file.z              -       File.z       **compare these two

 

The following is what I had but it obviously does not do what I need but I do not know where to go from here.

 

$Root1 = "C:\testfolder"

 

 

 

 

$Root2 = "D:\testfolder"

 

Compare-Object -ReferenceObject (Get-ChildItem -Path $Root1 | Get-ChildItem | Get-ChildItem -filter *.txt | get-content) -DifferenceObject (Get-ChildItem -Path $Root2 | Get-ChildItem | Get-ChildItem -filter *.txt | get-content) -IncludeEqual | Out-GridView

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles