PowerShell_Scripts/base/Remove-NoFileDirs.ps1

20 lines
527 B
PowerShell
Raw Normal View History

2021-11-29 22:00:43 +00:00
[CmdletBinding()]param(
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0,Mandatory)]
[Alias('FullName')]
[string[]]$Path
)
begin {}
process {
$Path |
Get-ChildItem -Directory -Recurse |
Where-Object {
0 -eq (Get-ChildItem -File -Recurse ($_.FullName -replace '([\[\]])','`$1')).Length
} |
ForEach-Object {
Write-Host "Removing $($_.FullName)..."
Remove-Item -Force -Recurse -LiteralPath $_.FullName
}
}
end {}