Skip to content

Instantly share code, notes, and snippets.

@Pavelyev
Created March 24, 2019 18:41
Show Gist options
  • Save Pavelyev/bae989862ce1bb18dbcd23e837405688 to your computer and use it in GitHub Desktop.
Save Pavelyev/bae989862ce1bb18dbcd23e837405688 to your computer and use it in GitHub Desktop.
$Path = "."
Get-ChildItem -path $Path -recurse |
Where {!$_.PSIsContainer -and $_.LastWriteTime -lt (get-date).addHours(-24)} |
Remove-Item
# removing empty folders
Get-ChildItem -path $Path -recurse |
Where {$_.PSIsContainer -and @(Get-ChildItem -Lit $_.Fullname -r |
Where {!$_.PSIsContainer}).Length -eq 0} |
Remove-Item -recurse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment