Windows batch file to delete folders/subfolders using wildcards

Posted by Marco Demaio on Stack Overflow See other posts from Stack Overflow or by Marco Demaio
Published on 2010-05-13T12:50:30Z Indexed on 2010/05/13 12:54 UTC
Read the original article Hit count: 287

I need to delete all folders in "tomin" folder, which name contains terminates with the ".delme" string. The deletion need to be done recurively: I mean on all directory and SUB directories.

I though to do this:

FOR /R tomin %%X IN (*.delme) DO (RD /S /Q "%%X")

but it does not work, I think /R ignores wildcards.

Before asking this quation I searched also in SO and found this: but the answers did not help me in solving my issue, following the suggestion given there I tried:

FOR /F tomin "delims=" %%X IN ('dir /b /ad *.delme') DO RD /S /Q "%%X"

But it did not work either.

Any help aprreciated, thanks!

© Stack Overflow or respective owner

Related posts about batch

Related posts about batch-file