# encoding: ascii
# api: powershell
# title: Delete Empty Folders
# description: This is a script to remove empty folders from a drive. I used it when i had to clear up a shared drive from a former company.
# version: 0.1
# author: Trevor Wilson
# license: CC0
# x-poshcode-id: 3690
# x-archived: 2017-02-28T13:02:08
# x-published: 2013-10-14T09:45:00
#
# Please let me know if you know a way i can improve it.
#
$Drive = Read-Host "Path to Folders"
Write-Host "This will delete all empty folders in this directory!"
$a = Get-ChildItem $drive -recurse | Where-Object {$_.PSIsContainer -eq $True}
$a | Where-Object {$_.GetFiles().Count -lt 1} | Select-Object FullName | ForEach-Object {remove-item $_.fullname -recurse}
Write-Host "All Done!"