Solved

delete sub-folders - batch script

Posted on 2006-11-07
3
426 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now