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?

1 Answer 1


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

for /d %%a in (*star*) do rd/s/q "%%a"

You must log in to answer this question.

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