Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For example I have many many directories, let's say dir1, dir2, dir3 and in each of that dir has subdir named tempdir.
I want to delete all files in tempdir from dir1 to dir3 without manually going to each directory and delete. The tempdir itself is deleted or not is not a problem. Tnx

share|improve this question

3 Answers 3

Try del /S directory

cd into the directory above, and execute that.

share|improve this answer
    
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. –  Al E. Jan 15 '10 at 15:51
    
That's probably a good idea, yeah. –  Phoshi Jan 15 '10 at 16:06
    
I added the /q switch so it wouldn't prompt ;) –  JefClaes Oct 2 '13 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 :)

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.