---
type: link
tags: [public]
created: 2025-10-27T09:17:57.483Z
---# powershell pwsh | delete all empty directories with variable saving pwd

**URL:** [https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-strings?view=powershell-7.1](https://docs.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-strings?view=powershell-7.1)

powershell pwsh | delete all empty directories with variable saving pwd # Get the current directory $currentDirectory = Get-Location # Recursively list all empty directories and delete them Get-ChildItem -Path $currentDirectory -Directory -Recurse | Where-Object { $_.GetFileSystemInfos().Count -eq 0 } | Remove-Item -Force


---
**Keywords:** public
