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
You're code works if the command is executed in the directory where the folders are looked for.
But since I am trying execute this command from any place it does not work.