Solved rmdir wildcard? Help needed

November 11, 2009 at 13:39:56
Specs: Windos 7, Intel i7 950
ok, so I have four folders in a directory. I want to delete them all command line in one command. naturally you think about using a wildcard. What is the wildcard for rmdir?

The four folders are something like j34orapatch10328, kjn783orapatchkjndf.

So Obviously I want to use the wildcard in the beginning and end, but don't know what it is. Any help? I've googled for about an hour.


See More: rmdir wildcard? Help needed

Report •


✔ Best Answer
November 12, 2009 at 02:23:13
Hi M2,

What about:

for /d %%a in (?*patch*) do rd /s /q "%%a"


Batch Variable how to



#1
November 11, 2009 at 13:47:03
rd *.

as in *=everything before the . dot

make sure of where you are when you issue the command!
adding /s will remove the folders as well as file they may contain.


Report •

#2
November 11, 2009 at 13:59:20
Ok, that is my fault.
The reason I can't do that is because there are some folders that I do need to keep within the directory. But I was told to use one command to delete all the folders with that phrase.

So, now that I've explained better, any ideas?


Report •

#3
November 11, 2009 at 14:10:54
You have to give more detailed informations on how the folder named, you'd like to delete and the names of the folders you will not delete.

Report •

Related Solutions

#4
November 11, 2009 at 14:24:21
You have to find what is in common with the folders you want to delete but not in common with the folders you don't want to delete.

for example you could do
rd *patch?????. to remove the two folders you posted


Report •

#5
November 11, 2009 at 14:41:18
I keep getting the filename, directory name, or volume label syntax is incorrect.

All folders have the word "patch" in its name. It has random letters numbers before and after.

The error I posted above i get when doing:

rmdir *patch*
or
rd *patch*

or

rd *patch???


Report •

#6
November 11, 2009 at 15:04:37
LOL rd won't take wildcards.

for /f "tokens=* delims= " %a in ('dir/b/ad ^| find "patch"') do (rd /s /q %a)


=====================================
Helping others achieve escape felicity

M2


Report •

#7
November 11, 2009 at 15:12:18
You are SO RIGHT!

Report •

#8
November 11, 2009 at 15:23:05
Former, DELTREE.EXE could be used for that and supports also wildcards.
Unfortunately DELTREE is no longer part of the OS since Windows 2000.

Report •

#9
November 11, 2009 at 18:42:14
With the above command, I get "in was unexpected at this time"

Report •

#10
November 11, 2009 at 19:02:59
You mean the one I posted in #6?


=====================================
Helping others achieve escape felicity

M2


Report •

#11
November 11, 2009 at 22:04:19
Yes, the one in #6 returns that error

Report •

#12
November 11, 2009 at 23:44:30
You got me there. It works on my W2K box. Which is more like XP than anything I know of.

If you put it in a script you need to double up the % signs.

================
@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/ad ^| find "patch"') do (rd /s /q %%a)


=====================================
Helping others achieve escape felicity

M2


Report •

#13
November 12, 2009 at 02:23:13
✔ Best Answer
Hi M2,

What about:

for /d %%a in (?*patch*) do rd /s /q "%%a"


Batch Variable how to


Report •

#14
November 12, 2009 at 02:55:25
I guess that'll do.


=====================================
Helping others achieve escape felicity

M2


Report •

#15
November 12, 2009 at 06:54:47
i just tried number 13's response (before #12, so 12 will also work) and I got it.

Thanks for the help guys.


Report •


Ask Question