powershell 删除 复制 遍历某个文件夹 脚本

$timeOutDay = 30
$filePath = "E:\log"

$allFile = Get-ChildItem -Path $filePath
$i = 0
foreach($file in $allFile)
{
$daySpan = ((Get-Date) - $file.LastWriteTime).Days
if ($daySpan -gt $timeOutDay)
{
copy-item -Path E:\log\ -DestinationPath G:\日志
}
$i=$i+1
}

posted @ 2020-11-13 13:54  Something_lzm  阅读(365)  评论(0)    收藏  举报