Deleting folders in a dir

  • Thread starter Thread starter Phil
  • Start date Start date
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
 
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
 
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 {} \;
 
Back
Top