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.

I need to delete a whole directory (with a lot of sub directories and files) by running a command in a batch file.

I tried delete and erase, but both of them requires me to answer 'Y/N', and it doesn't seem to delete the directories if one has subdirectories or files.

What command can I use to delete a directory with subdirectories/files without whatever prompt?

share|improve this question

3 Answers 3

up vote 11 down vote accepted
rmdir /s /q [directory]
share|improve this answer
    
You don't need to run del first, rmdir /s will delete the files too. –  Andrew Oct 28 '10 at 16:29

Try:

DEL /Q /S /F <FILE/DIR>

or

DELETE /Q /S /F <FILE/DIR>
share|improve this answer

I'm not sure if it's a valid command in the W7 CLI, but back when DOS was still DOS, it was as simple as:

deltree /y <dirname or path>
share|improve this answer
1  
deltree is not supported in Win7. –  prosseek Oct 28 '10 at 16:25

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.