I use Windows.
I want to delete all files and folders in a folder by system call.
I may call like that:
>rd /s /q c:\destination
>md c:\destination
Do you know an easier way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, I don’t know one.
If you want to retain the original directory for some reason (ACLs, &c.), and instead really want to empty it, then you can do the following:
This first removes all files from the directory, and then recursively removes all nested directories, but overall keeping the top-level directory as it is (except for its contents).
Note that within a batch file you need to double the
%within theforloop: