“PowerShell Exclua pastas vazias” Respostas de código

Powershell Obtenha pastas vazias

Get-ChildItem "C:\Scripts" -Recurse -Directory | Where-Object {!$_.GetFileSystemInfos().Count} | Select-Object FullName
Troubled Toad

PowerShell Excluir pasta

Remove-Item 'D:\temp\Test Folder1'
DevPedrada

PowerShell como remover apenas diretores vazios

# A script block (anonymous function) that will remove empty folders
# under a root folder, using tail-recursion to ensure that it only
# walks the folder tree once. -Force is used to be able to process
# hidden files/folders as well.
$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
    }
}
I'm Just Blue

PowerShell Exclua pastas vazias

$tdc="C:\a\c\d"
$dirs = gci $tdc -directory -recurse | Where { (gci $_.fullName).count -eq 0 } | select -expandproperty FullName
$dirs | Foreach-Object { Remove-Item $_ }
OldyGuy

Respostas semelhantes a “PowerShell Exclua pastas vazias”

Perguntas semelhantes a “PowerShell Exclua pastas vazias”

Mais respostas relacionadas para “PowerShell Exclua pastas vazias” em Shell/Bash

Procure respostas de código populares por idioma

Procurar outros idiomas de código