Remove wildcard directory...

Associate
Joined
18 Dec 2007
Posts
209
I'm being thick :(

I want to delete certain subdirectories in a folder using a batch file (scheduled) -e.g;

del "C:\Documents and Settings\xxx\Desktop\TEST DELETE\XXX*.*"
del "C:\Documents and Settings\xxx\Desktop\TEST2\XXX*.*"
pause

Where after the XXX could be any series of numbers... e.g. - XXX001, XXX002

I thought it would be something akin to; del "c:\xxx?.*"

Am I being a spaz?

Cheers!
 
try rmdir dude

rmdir /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S
 
Doh!

Cheers mate.

Still can't seem to get the wildcard searching work...

Say the folder was called - C:\TEST\XXX00001

I've tried;

  • rmdir "C:\TEST\XXX?????.*"
  • rmdir "C:\TEST\XXX?????"
  • rmdir "C:\TEST\XXX*.*"
  • rmdir "C:\TEST\XXX*"
  • rmdir "C:\TEST\XXX?"

Yet I keep getting file not found - having made the first mistake of using DEL rather than rmdir... what other spaz am I? :p
 
Barking up the wrong tree, RMDIR does not work with wildcards :(

Ended up with;

Code:
@echo off
cd TEST DELETE
for /D %%a in (*.*) do (
echo Directory %%a
rmdir %%a
)
pause
 
Back
Top Bottom