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

Compare files based on LastWriteTime if basename matches

$
0
0

I have two sets of files, one folder contains one filetype and another folder contains the other filetype.

 

Folder 1 has .filetype1
Folder 2 has .filetype2

Every file in folder1 has a matching partner in folder2. The common thing is .basename. To get files where basename matches i'm just doing:

$dir1 |where{$_.BaseName-in $dir2.BaseName}

 

this however is not possible to do when comparing .LastWriteTime as that function will match $_.LastWriteTime to any file in $dir2.LastWriteTime

Pseudo:

If $_.Basename -eq $dir2.basename find files where .LastWriteTime differs  <-- help is wanted


Viewing all articles
Browse latest Browse all 6937

Trending Articles