I have many many directories. Let's say dir1, dir2, dir3 and each directory has a subdirectory named tempdir.

I want to delete all files in tempdir from dir1 to dir3 without manually going to each directory. Whether the tempdir itself is deleted or not is not a problem.

3 Answers 3


Try del /S directory

cd into the directory above, and execute that.

  • You may wish to add the /p switch. That will prompt you before each delete. Might save you if the command looks to delete more than you wanted.
    – ale
    Commented Jan 15, 2010 at 15:51
  • That's probably a good idea, yeah.
    – Phoshi
    Commented Jan 15, 2010 at 16:06
  • I added the /q switch so it wouldn't prompt ;)
    – JefClaes
    Commented Oct 2, 2013 at 9:00

Go to Search and do a search for tempdir on the directories you want to scan. The take all the results and press delete.

Damm easy :)


This may not be for everyone but I love it, understand a few things first.
1) I like and use command line stuff because create batch files to do redundant tasks is preferable to me.
2) I always extend my command line capabilites using standard gnu linux commands ported to windows. They can be found at http://sourceforge.net/projects/unxutils/. I just take the exe files I am interested out of the ZIP file (they are located in the /usr/local/wbin directory of the ZIP) and place them in some directory in my path. Because I use them so often I actually place them all in a /unix directory and put that first in the path.
3) For this task the utilities specifically needed are find and rm. If you get a conflict with the find command and the Windows find, just use the whole path in the command.

To focus in on just deleting the tempdir directories, assuming that there may be other files or directories within dir1 dir2 dir3, I would do the following.

Go to the directory which is the parent of dir1 dir2 dir3 and run

find . -name tempdir -type d -depth -ok rm -rf {} ;

meaning the following

find .          - Start in this directory and find something for me.
-name temdir    - The name of what we are looking for.
-type d         - Look for directories (named as above).
-depth          - Look down the tree first so if you remove something it won't complain.
-ok rm -rf {} ; - The real power ok just means to ask before doing anything, 

if ok is replace with exec then it will just to it. So do the following rm -rf on all matching "found entries" or in other words remove recursively forcing removal all directories named temdir

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .