recursion - How I can copy/move folder and files recursive than x Days old in Powershell? -


i want copy files b in powershell. want copy files older $days. works if have folder old files , 1 file new, function doesn't copy folder old files.

here code:

function copyfolder($source,$destination,$lastwrite){      foreach($files in get-childitem $source -recurse | {$_.lastwritetime -le $lastwrite}){           foreach($file in $files){                  if($file -ne $null){                       copy-item $file.fullname -destination $destination -recurse                 }          }     }   }  #anfangspunkt (a) $path = "c:\users\tarasov_w\downloads" #ziel (b) $destination = "c:\users\tarasov_w\desktop\ps_test"  $now = get-date $days = 5 $lastwrite = $now.adddays(-$days);  copyfolder -source $path -destination $destination -lastwrite $lastwrite 


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -