compare 1 source folder with x of other folders

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Dave Wyatt Dave Wyatt 2 years, 1 month ago.

  • Author
    Posts
  • #20458
    Profile photo of Ian
    Ian
    Participant
    
    $a ="C:\TEMP\location1", "C:\TEMP\location2", "C:\TEMP\location3"
    
    
    $source = get-childitem "C:\TEMP\source" -Recurse
    
    $location1 = get-childitem $a[0] -Recurse
    $location2 = get-childitem $a[1] -Recurse
    $location3 = get-childitem $a[2] -Recurse
    
    Compare-Object $source $location1 -Property Name, Length, LastWriteTime
    
    #Compare-Object $source $location2 -Property Name, Length, LastWriteTime
    
    #Compare-Object $source $location3 -Property Name, Length, LastWriteTime
    

    there has to be a better way to do this!

  • #20459
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    I would probably use robocopy for this. It has some switches that allow you to compare folders without actually changing anything (though it wouldn't give you PowerShell objects to work with; just text. It's good for the command line, though.)

    There are plenty of examples of this on the web; this one was at the top of my search results: http://improvingsoftware.com/2013/09/09/how-to-diff-two-folders-from-a-windows-command-prompt/

You must be logged in to reply to this topic.