0

I am trying to write a batch that deletes multiple directories/folders in a directory

I am using

for /D %f in (*) do rmdir %f /s /q

Now this works and deletes folder names that dont contain a space.

I recieve this message after running the above command for the folders that do.

d:\test\testworld\rmdir remove me /s /q

The system cannot find the file specified.
The system cannot find the file specified.

Most of the folders contain spaces. Is there anyway i could change the command to include folders with spaces?

SeanC
  • 15,695
  • 5
  • 45
  • 66
Phill
  • 11
  • 1
  • 2

2 Answers2

4

use quotes.

rmdir remove me /s /q

fails, but

rmdir "remove me" /s /q

works.

The change to your command line would be for /D %f in (*) do rmdir "%f" /s /q

SeanC
  • 15,695
  • 5
  • 45
  • 66
  • Sean thank you very much i spent 18 hours looking around the web for this answer. you solved it in 1 hour. your a god cheers – Phill Oct 18 '12 at 17:52
2

You can use " double quotation mark like rmdir "remove me" /s /q

Ozgur
  • 258
  • 3
  • 13