Solved

delete sub-folders - batch script

Posted on 2006-11-07
3
434 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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