Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Compare-object then conpare date modified

$
0
0

Hi,

I am comparing 2 folders and copying the different files.  Unfortunately I have some files (after a specific date) that I don't want to copy.  Can I exclude these files using date modified property?  Here is what I have so far:

$source = 'e:\folder1'
$destination = 'e:\folder2'

#Compare the 2 folders
Compare-Object $Folder1 $Folder2 -Property Name | Where-Object {$_.SideIndicator -eq "<="} | ForEach-Object {

#Sudo code
If date modified less than 10 days

       Copy-Item "$source\$($_.name)" -Destination "$destination" -Force
#write-host $source\$($_.name) -foregroundcolor red
        }

Thanks

James


Alter De Ruine


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>