How to Delete folders by wildcard search? Answer: use PowerShell


I had a requirement to delete directories by wildcard. Unfortunately RMDIR  User* will not work in command prompt. I found the answer in PowerShell. The following command delete a bunch of folders by wildcard selection.
 
The following command deletes all folders starting with "2008*" under C:program FilesDBappLogs.
 
get-childitem -path ‘C:Program FilesDBappLogs’ -filter 2008* | remove-item -force -recurse
 
The follwoing command deletes all folders starting with anand* under \servernamec$documents and settings
 
get-childitem -path ‘\servernamec$documents and settings’ -filter anand* | remove-item -force -recurse
 
If it helps you, I am glad for you. smile_shades

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s