如何从当前目录中删除文件夹及其所有内容?

mis*_*das 37 windows batch-file

此代码不起作用:

@echo off

if exist output @set /p checkdir= Output directory found. Do you wish to overwrite it?:

if  /I %checkdir% == Y  deltree /s /output 
pause
Run Code Online (Sandbox Code Playgroud)

web*_*rik 85

您正在寻找此命令:

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
Run Code Online (Sandbox Code Playgroud)

在您的情况下只需使用/ S ,它将首先询问用户是否应继续删除整个目录树,即 - 将以下输出显示在屏幕上:

"folderName, Are you sure (Y/N)?"

folderName您要删除的文件夹(及其子文件夹)的名称在哪里.

在Windows 7,64位上测试.