“PowerShell Hapus folder kosong” Kode Jawaban

PowerShell dapatkan folder kosong

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

Folder Hapus PowerShell

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

PowerShell Cara Menghapus Hanya Direcoties Kosong

# 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 Hapus folder kosong

$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

Jawaban yang mirip dengan “PowerShell Hapus folder kosong”

Pertanyaan yang mirip dengan “PowerShell Hapus folder kosong”

Lebih banyak jawaban terkait untuk “PowerShell Hapus folder kosong” di Shell/Bash

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya