Skip to content

Instantly share code, notes, and snippets.

@stefango
Created April 2, 2021 06:30
Show Gist options
  • Save stefango/80015600d7591b2d2152c5de5b7ed5bb to your computer and use it in GitHub Desktop.
Save stefango/80015600d7591b2d2152c5de5b7ed5bb to your computer and use it in GitHub Desktop.
delete.psl
# delete empty folders
$tdc="DIRECTORY"
do {
$dirs = gci $tdc -directory -recurse | Where { (gci $_.fullName -Force).count -eq 0 } | select -expandproperty FullName
$dirs | Foreach-Object { Remove-Item $_ }
$count = $count + 1
} while ($dirs.count -gt 0)
echo 'empty folders deleted'
# delete files in specific format
rm -Force "\FileStorage\File\*\*.gif"
rm -Force "\Downloads\*.license"
# delete log
rm -Force "\Downloads\*downLog*"
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment