Deleting folders in a dir

P

Phil

I'm trying to write a batch file which will delete any folders (and their
contents) that are contained within a dir, but none of the files that are in
the root of that dir.

The folders that are in the dir could have any name so it is impossible to
know what they may be called.

Been looking around but can't seem to find any way of doing this

I know that this might not really be the right newsgroup to use, but there
doesn't seem to be one that seems suitable. Hope you don't mind.

Has anyone got any ideas/tips?

Cheers for any help

Phil
 
N

Norman Bullen

Phil said:
I'm trying to write a batch file which will delete any folders (and their
contents) that are contained within a dir, but none of the files that are in
the root of that dir.

The folders that are in the dir could have any name so it is impossible to
know what they may be called.

Been looking around but can't seem to find any way of doing this

I know that this might not really be the right newsgroup to use, but there
doesn't seem to be one that seems suitable. Hope you don't mind.

Has anyone got any ideas/tips?

Cheers for any help

Phil

You can probably do this with some combination of FOR statements. Type
HELP FOR > for.txt at the command line to get a long document about the
FOR command.

A gentleman named Timo Salmi regularly posts links to his Command Line
Scripting FAQ on comp.os.ms-windows.misc. There may be something in
there that you can use. Here's the link:
ftp://garbo.uwasa.fi/pc/link/tscmd.zip

Norm
 
G

Guest

If you don't mind installing posix-ish tools like cygwin:

# use $rootdir/*, not $rootdir to keep
# $rootdir out of the results
find $rootdir/* -type d -exec rm -rf {} \;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top