批处理文件不处于静默模式 del /s /q /f 文件

Hea*_*ven 4 batch-file

当我在 cmd 中或作为批处理文件运行此命令时,它不会像 /q 那样以静默模式运行,而是显示“已删除的文件 - 文件”

del /s /q /f file
Delteded file - file
Run Code Online (Sandbox Code Playgroud)

我希望这也能帮助其他人

小智 5

事实上,安静模式意味着删除时不会要求您确认:

/Q 安静模式,不询问是否可以在全局通配符上删除

>del /?
Deletes one or more files.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

  names         Specifies a list of one or more files or directories.
                Wildcards may be used to delete multiple files. If a
                directory is specified, all files within the directory
                will be deleted.

  /P            Prompts for confirmation before deleting each file.
  /F            Force deleting of read-only files.
  /S            Delete specified files from all subdirectories.
  /Q            Quiet mode, do not ask if ok to delete on global wildcard
  /A            Selects files to delete based on attributes
  attributes    R  Read-only files            S  System files
                H  Hidden files               A  Files ready for archiving
                I  Not content indexed Files  L  Reparse Points
Run Code Online (Sandbox Code Playgroud)

为了不显示输出,您必须将其重定向到 NUL。从批处理如何...显示和重定向输出

del /s /q /f file > NUL
Run Code Online (Sandbox Code Playgroud)