Common Paths In 2 Separate CSV Files

Welcome Forums General PowerShell Q&A Common Paths In 2 Separate CSV Files

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
1 week, 6 days ago.

  • Author
    Posts
  • #138665

    Participant
    Points: 29
    Rank: Member

    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

     

     

  • #138672

    Participant
    Points: 736
    Helping Hand
    Rank: Major Contributor

    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
  • #138675

    Participant
    Points: 29
    Rank: Member

    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!

    • #138678

      Participant
      Points: 736
      Helping Hand
      Rank: Major Contributor

      😀

You must be logged in to reply to this topic.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort