Reputation: 11
If you create multiple directories within each other using Powershell is it possible to remove them all at once? The rmdir command removes them one at a time, but I was wondering if there was a more simple way.
Thank you!
I'm just learning to code through Powershell, so any tips or tricks are appreciated!
Upvotes: 1
Views: 1406
Reputation: 12453
If by WITHIN each other you mean directories that all share a common ancestor, you can delete the common ancestor and all descendants recursively:
Remove-Item -Recurse -Force DirectoryToDelete
Note that this can also be done using the rmdir command with the /s switch.
Upvotes: 1