powershell 刪除目錄內所有文件修改時間超過timeOutDay的文件。

http://www.cnblogs.com/xiongpq/p/3543229.html


$timeOutDay = 30
$filePath = "H:\DataBackup\File\1",
"H:\DataBackup\Database\2"

$allFile = Get-ChildItem -Path $filePath

foreach($file in $allFile)
{
    $daySpan = ((Get-Date) - $file.LastWriteTime).Days
    if ($daySpan -gt $timeOutDay)
    {
        Remove-Item $file.FullName -Recurse -Force
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章