Avoid File not found in dir command - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Avoid File not found in dir command

dan19dan19 Posts: 7Member
I am trying to delete from a folder all the folders that have a specific name like this

for /f "delims=" %%i in ('dir /b /ad /s CVS*') do rmdir /s /q %%i

The problem is that if the command 'dir /b /ad /s CVS*' returns the 'File Not Found' and the 'for' command will iterate over all the folders in my directory

Is there a way to make the command work in both cases: when folders exist and when they don't


Sign In or Register to comment.