Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ErrorActionPreference = 'SilentlyContinue'
- ## Function to Delete empty folders
- $tailRecursion = {
- param(
- $Path
- )
- foreach ($childDirectory in Get-ChildItem -Force -LiteralPath $Path -Directory) {
- & $tailRecursion -Path $childDirectory.FullName
- }
- $currentChildren = Get-ChildItem -Force -LiteralPath $Path
- $isEmpty = $currentChildren -eq $null
- if ($isEmpty) {
- Write-Verbose "Removing empty folder at path '${Path}'." -Verbose
- Remove-Item -Force -LiteralPath $Path
- }
- }
- cls
- $Location=$(get-location).Path;
- & $tailRecursion -Path "$Location"
Add Comment
Please, Sign In to add comment