Solved

delete sub-folders - batch script

Posted on 2006-11-07
3
430 Views
Last Modified: 2008-03-17
I have my project solution folder that contains multiple projects. These project folders again contain "bin" and "obj" folders. I want to write a small batch script that deletes these bin and obj folders. I am using Windows XP and don't find deltree command. And rd /s needs the folder name. Am I missing any other command? how can i delete sub-folders?
0
Comment
Question by:srinivas_vemla
  • 2
3 Comments
 
LVL 15

Expert Comment

by:ozymandias
ID: 17891052
OK. Be real careful with this :

for /D %d in (*) DO rd %d\bin

This is the for command.
For more details type for /? at a command prompt.

The above command says :

for  - command
/D - match directories only
%d a variable tp represent each item in the set
in (*) - this is a set which can use wildcards but it can be a list like (dir1,dir2,dir3,etc).
DO command - the command to execute for each item in the set
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 125 total points
ID: 17891063
this command will execute the command rd directoryname/bin for each and every directory in the current working directory
you can then do another one that does :

for /D %d in (*) DO rd %d\obj
0
 

Author Comment

by:srinivas_vemla
ID: 17891739
thanks gzymandias,
the for look was helpful...
but, I don't want to add "\obj" to all the child directories, but rather want to search these folders and then remove them...

so I came up with this:

dir /b /s bin, obj > temp.txt
for /F "delims=" %%d in (temp.txt) do rd /s /q "%%d"

and it works...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question