开发者

Windows batch file to delete folders/subfolders using wildcards

开发者 https://www.devze.com 2022-12-30 17:52 出处:网络
I need to delete all folders in \"tomin\" folder, which name contains terminates with the \".delme\" string.

I need to delete all folders in "tomin" folder, which name contains terminates with the ".delme" string. The dele开发者_Go百科tion 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 question 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.


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

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

Should do the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消