I am copying 10,000 files from one directory to another directory.
Both directory structures have the same files; however, the sizes might be different.
How do I force overwriting on files that have different sizes and DO NOT copy files that are the same size?
So far I have this:
$source = 'D:\Test1'
$destination = 'D:\test2'
$exclude = @('*.db','test2.log')
$sourcelist = Get-ChildItem $source -exclude $exclude
foreach ($file in $sourcelist){
$result = test-path -path "$destination\*" -include $file
if ($result -like "False"){
#uncomment the next line to see the value being passed to the $file parameter
#Write-Host $file
Copy-Item "$file" -Destination "$destination"
}
}
I think that will copy files that do not exist on the destination. However, I also want to copy files that DO exist but where their size differs.