---
type: link
tags: [link]
created: 2025-11-06T02:51:46.19+00:00
updated: 2026-01-02T01:39:32.364Z
---# 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:** link
