CMD: How do I delete all the contents of all directories (in the current directory) without deleting the directories themselves?

Posted by merlin2011 on Super User See other posts from Super User or by merlin2011
Published on 2011-12-11T01:30:38Z Indexed on 2012/11/13 23:09 UTC
Read the original article Hit count: 234

Filed under:
|

For example:

I'm in the directory:

F:\Data

Inside this directory, I have four directories:

F:\Data>dir
22179 22915 23459 23460

These directories have various content, including directories and files. I'm trying to run something like:

rmdir /s *\*

where I delete all the contents of these numbered directories, while leaving the empty directories. Is there a one-liner that can do this, or do I have to loop through the sub-directories?

© Super User or respective owner

Related posts about batch-file

Related posts about command-line