用于删除扩展名为.bak的文件的批处理文件

Swe*_*per 18 batch-file delete-file

在批处理中,我想删除磁盘上各种文件夹中的所有文件*.bak c:\.
谁能帮我?

例:

all c:
del *.bak /s /a
Run Code Online (Sandbox Code Playgroud)

谢谢.

fox*_*ive 28

它可以是一个命令.

del /s /q /f c:\*.bak
Run Code Online (Sandbox Code Playgroud)

  • 你能解释一下 /s /q 和 /f 参数的作用吗? (2认同)

Ken*_*ite 15

做全局删除时要格外小心!你可能会得到比你要求更多的东西,特别是在头痛和恢复你的系统时损失的方式.

话虽如此:

C:
cd \
del /s /q /f *.bak
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请del /?在命令提示符下键入,在Windows 7中为您提供:

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
                -  Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.
Run Code Online (Sandbox Code Playgroud)