Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of folders, some with spaces in their folder names and some not. They all have a certain string common in their folder names and they all lie inside a single directory. For e.g

  • new star folder
  • mystarfolder
  • somestar folder
  • starfolder

I want to delete all the above folders in a batch file. I tried the following, but it doesn't work with spaces in folder names

FOR /D %%A IN (*star*) DO RD /Q /S %%A

How to do it? May be I could use 8.3 names, but how to use it in the above command?

share|improve this question
up vote 1 down vote accepted

...Put quotes around the name: "%%A"

for /d %%a in (*star*) do rd/s/q "%%a"
share|improve this answer
    
Thanks a lot. That did the trick. – ontherocks Jun 12 '12 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .