Question

I am trying to create a DOS batch file that will delete all folders starting with the number 20 using the following command: "del /Q ".

I am running this on a Windows 2000 Pro PC.

Was it helpful?

Solution

for /f "delims=" %%d in  ('dir /ad /b ^| findstr /i /b "20"') do rd /s  /q "%%~dpfnd"

OTHER TIPS

This seems to work.

@echo off &setlocal
pushd "C:\your\directory" ||goto :eof
for /f "delims=" %%a in ('dir /ad /b /s ^|findstr /rc:"\\[20]"') do rd /s /q "%%~a"
popd
pause
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top