PowerShell: list empty dir 📜
List Empty Directories
function xah-list-empty-dir { # .DESCRIPTION # list empty dirs in current dir, recursively # .NOTES # Version: 2022-03-03 2023-08-17 # .LINK # http://xahlee.info/powershell/powershell_list_empty_dir.html Get-ChildItem -Directory -Recurse | Where-Object { $_.GetFileSystemInfos().Count -eq 0 } }
Delete Empty Directories
function xah-delete-empty-dirs { # .DESCRIPTION # delete empty dirs in current dir, recursively # .NOTES # Version: 2022-12-12 2024-05-03 # .LINK # http://xahlee.info/powershell/powershell_list_empty_dir.html $empdirs = Get-ChildItem -Directory -Recurse | Where-Object { $_.GetFileSystemInfos().Count -eq 0 } Write-Host "Deleting:" $empdirs | ForEach-Object { $_.fullname } | Out-Host $empdirs | Remove-Item -Confirm }
PowerShell. Directories and operations
List Dirs
- PowerShell: navigate directory
- PowerShell: show current dir path
- PowerShell: list directories
- PowerShell: show directory as tree
- PowerShell: list empty dir 📜
- PowerShell: dir size 📜