Solved

delete multiple directories from command line

Posted on 2008-10-17
7
1,132 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
Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

 
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 84

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

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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