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

时间:2014-04-04 19:31:25

标签: batch-file delete-file

批处理时,我想删除磁盘c:\上各种文件夹中的所有文件* .bak 任何人都可以帮助我吗?

例如:

all c:
del *.bak /s /a

谢谢。

2 个答案:

答案 0 :(得分:26)

它可以是一个命令。

del /s /q /f c:\*.bak

答案 1 :(得分:14)

在进行全局删除时要格外小心! 您可能会得到比您要求更多的内容,尤其是在恢复系统时头痛和失去时间的方式。

话虽如此:

C:
cd \
del /s /q /f *.bak

有关详细信息,请在命令提示符下键入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.