Skip to content

Instantly share code, notes, and snippets.

@manchot0
Created July 26, 2021 08:29
Show Gist options
  • Select an option

  • Save manchot0/91c959c45750537e7936a50345af2154 to your computer and use it in GitHub Desktop.

Select an option

Save manchot0/91c959c45750537e7936a50345af2154 to your computer and use it in GitHub Desktop.

Revisions

  1. Timothe created this gist Jul 26, 2021.
    9 changes: 9 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #clean recursively all files older than 180 days in the given path

    $filterDate = (Get-Date).AddDays(-180).Date

    Get-ChildItem E:\DIR_PATH -Directory | ForEach-Object {

    Get-ChildItem $_.FullName -Recurse | Where {$_.lastwriteTime.Date -le $filterDate } | Remove-Item

    }