2019年8月6日 星期二

自動N天刪除 PowerShell、批次檔BAT

PowerShell
get-childitem 路徑 | where {$_.lastwritetime -lt (get-date).adddays(-7)} |% {remove-item $_.fullname} 


【批次檔】


REM Remove files older than 7 days 
forfiles /p "路徑" /s /m *.* /c "cmd /c Del @path" /d -7



沒有留言:

張貼留言

自動N天刪除 PowerShell、批次檔BAT

【 PowerShell 】 get-childitem 路徑 | where {$_.lastwritetime -lt (get-date).adddays(-7)} |% {remove-item $_.fullname}  【批次檔】 REM Remov...