Common Paths In 2 Separate CSV Files


I want to compare compare the contents of 2 folders but I only have access to my copy of the folder in question and the contents of the folders in question are both large as well as sensitive in parts so copying the files alongside each other and comparing them directly is not an option.

As such I was hoping I could catalog the entire folder structure in a file my end (I thought CSV - but I’m easy on the format really) and forward the PowerShell I use to the person at the other side so they could produce the same detail. We could then compare the catalog files produced to look for differences.

To give some context - I’m essentially trying to troubleshoot why something doesn’t work at the other end and reviewing the traits of the 2 sets of (what should be identical) files for clues

I’m almost there - using the PS command at the bottom of the post - but the parent folders of the 2 folders in question differ and I’d like them to list the same - e.g) My Folder structure is say c:\Test\Files\dir1\dir2 and theirs is g:\share\test\Files\dir1\dir2.

I’d like the paths listed in both catalog files to be common - i.e. simply be \Files\dir1\dir2

How do I achieve this folks?



$Files = @(Get-ChildItem -Path $Path -file -Recurse) | Select-Object name, directory,lastwriteTime, @{ Label = ‘File Version’; Expression = { $_.VersionInfo.FileVersion }},FullName | Export-Csv “$env:TEMP\Files.csv” -force -NoTypeInformation




you should start with formatting your code as code here in the forum. Thanks. :wink:

Something like this could work:

Get-ChildItem -Path $Path -File -Recurse |
Select-Object -Property Name, Directory,LastwriteTime,
@{ Name = ‘FileVersion’; Expression = { $.VersionInfo.FileVersion }},FullName,
@{Name = ‘RelativePath’; Expression={$
.FullName -replace [REGEX]::Escape($Path)}} |
Export-Csv “$env:TEMP\Files.csv” -Force -NoTypeInformation

Hi Olaf

Exactly what I was after!

Thanks for that - and apologies for the faux pas on not formatting the code on my original post! I’ll try and remember next time around!