PoshCode Archive  Artifact [039b83d772]

Artifact 039b83d77237a814e9548c0b8ca9b06ae77356a9f779f684d4180f2998624bec:

  • File Delete-Empty-Folders.ps1 — part of check-in [b361446c1f] at 2018-06-10 13:29:31 on branch trunk — 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. (user: Trevor Wilson size: 761)

# 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!"