MS-DOS

Moderators: blip
Number of threads: 362
Number of posts: 872

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Avoid File not found in dir command Posted by dan19 on 2 Nov 2011 at 3:47 AM
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
Report
Re: Avoid File not found in dir command Posted by rookkey on 8 Nov 2011 at 2:24 PM
for /R /D %%i in (CVS*) do rmdir /s /q "%%i"

Report
Re: Avoid File not found in dir command Posted by dan19 on 9 Nov 2011 at 10:18 PM
Thank you. It works
Report
Re: Avoid File not found in dir command Posted by dan19 on 14 Nov 2011 at 2:25 AM
I spoke too soon

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.
Report
Re: Avoid File not found in dir command Posted by rookkey on 14 Nov 2011 at 7:59 PM
for /D /R "C:\temp\AFolder" %%i in (CVS*) do rmdir /s /q "%%i"




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.