Solved

delete multiple directories from command line

Posted on 2008-10-17
7
1,134 Views
Last Modified: 2010-04-21
Hello,

I am trying to delete a bunch of directories from the command line in Windows.  I am getting  syntax not correct error.  Al of the folders I want to delete begin with IMG.

The command I am running is RD img* /s /q.

If I put in the full folder name, it works, but I need to run this from a batch file and the folder names are always different at the end.
0
Comment
Question by:caw01
[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
  • 4
  • 2
7 Comments
 
LVL 4

Expert Comment

by:michote
ID: 22745509
wild cards are not permited with this command, you will need a different utility
0
 
LVL 4

Accepted Solution

by:
michote earned 250 total points
ID: 22745525
0
 

Author Comment

by:caw01
ID: 22745584
Is that a VB script?  How do I run that?
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 4

Expert Comment

by:michote
ID: 22745708
http://en.wikipedia.org/wiki/VBScript

The short version is you already have it installed, just copy the script on notepad, and give it a .vbs extention. that is it. run it.
0
 
LVL 85

Assisted Solution

by:oBdA
oBdA earned 250 total points
ID: 22745987
It's actually a simple one-liner in the command prompt:
for /d %a in (img*) do @echo rd /s /q "%a"

"for /d" will create a loop and process every *d*irectory in the current folder beginning with "img"; the currently processed folder will be in the variable %a (enter "help for" for details).
The command above will not do anything except echo out the rd "commands" it would otherwise run, so that you can test it.
To run it for real, just remove the @echo (the "@" in front of a command will just suppress echoing the command itself):
for /d %a in (img*) do rd /s /q "%a"
0
 
LVL 4

Expert Comment

by:michote
ID: 22746069
That solution is also in the Link I posted.
0
 

Author Closing Comment

by:caw01
ID: 31507317
I used the the vb script, but the other command woul dprobably have worked too...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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