Created
March 24, 2019 18:41
-
-
Save Pavelyev/bae989862ce1bb18dbcd23e837405688 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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