What's the Equivalent to 'Rm -Rf' with Windows Command?

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?

3 Answers

rmdir /s /q [directory]
0

Try:

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

or

DELETE /Q /S /F <FILE/DIR>
0

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>
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest