返回列表 发帖
本帖最后由 newswan 于 2024-6-13 11:40 编辑

powershell 比较简单
  1. $sour = "D:\work"
  2. $dtFormat = "yyyy-MM-dd"
  3. $days = -7
  4. Push-Location -Paht $sour
  5. Get-ChildItem -Directory | ForEach-Object {
  6. $dt = [DateTime]::ParseExact( $_.name , $dtFormat , $null )
  7. if (  $dt -lt (Get-Date).AddDays( $days ) ) {
  8. Remove-Item -Path $_ -Recurse -Force
  9. }
  10. }
  11. Pop-Location
复制代码

TOP

返回列表