Reputation: 85
I need your help for writing a little batch script in order to delete specific named folders inside a path.
Let's image we have multiple folders called "pippo"
inside the path tree "C:\Users\myUser\Desktop\StartFolder"
How can I write a script that browses all the folder tree of that path and delete all fsubolders called "pippo"
?
Thanks!
I found this command in other site
for /d /r "%d" %d in (_svn) do @if exist "%d" rmdir "%d"
So I tried to adapt it to my target, but it doesn't work.
for /d /r "C:\Users\myUser\Desktop\StartFolder" "pippo" in (_svn) do @if exist "pippo" rmdir "pippo"
Upvotes: 0
Views: 125
Reputation:
It's unclear to me what the _svn
is meant for in your tries.
( or is _svn
your real pippo
?)
for /r "C:\Users\myUser\Desktop\StartFolder" /d %%A in (pippo
) do if exist "%%~fA" echo rmdir "%%~fA"
If the output looks OK, remove the echo
in front of rmdir
Sample output on my test tree:
> for /r "q:\Test\2018" /D %A in (05) do @if exist "%~fA" @echo rd "%~fA"
rd "q:\Test\2018\05"
rd "q:\Test\2018\04\05"
rd "q:\Test\2018\05\05"
Upvotes: 1