delete folder starting with number

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
zackysue
Posts: 4
Joined: 20 Oct 2009 03:19
Location: kuala lumpur
Contact:

delete folder starting with number

#1 Post by zackysue » 01 Dec 2010 03:53

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

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: delete folder starting with number

#2 Post by aGerman » 01 Dec 2010 12:28

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

zackysue
Posts: 4
Joined: 20 Oct 2009 03:19
Location: kuala lumpur
Contact:

Re: delete folder starting with number

#3 Post by zackysue » 02 Dec 2010 00:46

thank e german,

for woriking script..

:D

Post Reply