Windows batch file to delete folders / subfolders using wildcards

I need to delete all folders in the "tomin" folder, whose name ends with the symbol ".delme". Removing should be done recursively: I mean all directories and SUB directories.

I want to do this:

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

but it doesn't work, I think / R ignores wildcards.

Before asking this question, I also searched in SO and found this : but the answers did not help me solve my problem, following the suggestion there:

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

But that didn't work either.

+4
source share
1 answer

Your first command will work, but you forgot to /D specify that you want directories.

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

Gotta do the trick.

+11
source

Source: https://habr.com/ru/post/1309662/


All Articles