# Common Paths In 2 Separate CSV Files

**URL:** <https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019>\
**Category:** PowerShell Help\
**Created:** [February 8, 2019, 9:29am UTC](https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019 "2019-02-08T09:29:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamt2776](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@adamt2776](https://forums.powershell.org/u/adamt2776)\
**Post date:** [February 8, 2019, 9:29am UTC](https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019/1 "2019-02-08T09:29:29Z")

</div>

Hi

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?

Thanks

Adam

$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

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 8, 2019, 10:42am UTC](https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019/2 "2019-02-08T10:42:40Z")

</div>

Adam,

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

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
```

---

<div class="post-metadata">

**Author:** ![adamt2776](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@adamt2776](https://forums.powershell.org/u/adamt2776)\
**Post date:** [February 8, 2019, 11:13am UTC](https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019/3 "2019-02-08T11:13:46Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [February 8, 2019, 11:16am UTC](https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019/4 "2019-02-08T11:16:20Z")

</div>

😃

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/common-paths-in-2-separate-csv-files/12019/5 "2024-05-16T20:33:24Z")

</div>


