如何在Windows中使用bat文件删除文件夹和所有内容?


142

我想使用bat文件删除包含所有文件和子文件夹的文件夹。

我已经尝试了以下方法,但是它不起作用:

@DEL D:\PHP_Projects\testproject\Release\testfolder*.*

有人可以帮忙吗?

Answers:


258
@RD /S /Q "D:\PHP_Projects\testproject\Release\testfolder"

说明

删除(删除)目录。

RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path

/S      Removes all directories and files in the specified directory
        in addition to the directory itself.  Used to remove a directory
        tree.

/Q      Quiet mode, do not ask if ok to remove a directory tree with /S

31
  1. del /s /q c:\where ever the file is\*
  2. rmdir /s /q c:\where ever the file is\
  3. mkdir c:\where ever the file is\

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.