Page 1 of 1

delete folder starting with number

Posted: 01 Dec 2010 03:53
by zackysue
hi there

need your help guys

i want to delete folder in subdirectory that starting with number only

e.g 00,01,2,000

thank you

zack

Re: delete folder starting with number

Posted: 01 Dec 2010 12:28
by aGerman
Try something like that:

Code: Select all

@echo off &setlocal
pushd "C:\your\directory" ||goto :eof
for /f "delims=" %%a in ('dir /ad /b /s ^|findstr /rc:"\\[0-9]"') do ECHO rd /s /q "%%~a"
popd
pause

Change the path behind the PUSHD command and run the code to show what would happen.
If youre sure the code would delete the right folders then remove the ECHO command and run it again ...

Regards
aGerman

Re: delete folder starting with number

Posted: 02 Dec 2010 00:46
by zackysue
thank e german,

for woriking script..

:D