I am aware that RMDIR /S /Q will delete any directory in a quiet way even if it has content.
However, it does not allow the use of wild char for the removal in batch mode.
How can I accomplish the task of deleting several directories at once at the command line?
e.g.

C:\ByeBye>
SL2007Ext1
SL2007Ext2
SL2007Ext3
...

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

Hmm not sure if it's easy for windows. Linux would be another matter as I'm sure you already know.

The best I could come up with was using...

dir SL2007Ext*

to list all the directories.

I tried using

rd SL2007Ext*

but that didn't work.

Since I don't know Windows scripting in vbs, and having a version of the GNU Minimalistic (MSYS) installed, it occurred to me to use what I know. rm -r SL2007Ext? That did the trick.

However, further experimenting proved fruitful with FOR FOR /D %G IN ( SL2007Ext? ) DO RMDIR /S /Q %G Credits go to Dave Sinkula that initially pointed me to it, and encouraged me to post the solution for future searches.
If you want to include it in a batch script an extra % needs to be included in the variable.
e.g. FOR /D %%G IN ( SL2007Ext? ) DO RMDIR /S /Q %%G

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.