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!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

Comments

Sign In or Register to comment.