Delete all folders containing a string
Posted: 21 Jul 2011 06:40
Hello I want to make a batch that deletes these folders and all their contents:
C:\found.000\, C:\found.001\, C:\found.002\, etc
or more accurately %systemdrive%\found.000
So far I have this:
for /d %%X in (found.0*) do rd /a /f /s /q "%%X"
However, this only does it if the current directory is C:\
I've tried playing around with adding the directory but it only seems to work when when the current directory is set to certain folders.
Can anyone make a better solution? Ideally I want:
Delete all folders in %systemdrive% containing found.0*
Thanks in advance
C:\found.000\, C:\found.001\, C:\found.002\, etc
or more accurately %systemdrive%\found.000
So far I have this:
for /d %%X in (found.0*) do rd /a /f /s /q "%%X"
However, this only does it if the current directory is C:\
I've tried playing around with adding the directory but it only seems to work when when the current directory is set to certain folders.
Can anyone make a better solution? Ideally I want:
Delete all folders in %systemdrive% containing found.0*
Thanks in advance