【问题标题】:Batch file to delete files with .bak extension用于删除扩展名为 .bak 的文件的批处理文件
【发布时间】:2014-04-04 19:31:25
【问题描述】:

我想批量删除磁盘c:\上各个文件夹中的所有文件*.bak。
谁能帮帮我?

例如:

all c:
del *.bak /s /a

谢谢。

【问题讨论】:

    标签: batch-file delete-file


    【解决方案1】:

    在进行全局删除时要格外小心!您可能会得到比您要求的更多的东西,尤其是在头疼和浪费时间恢复系统方面。

    话虽如此:

    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.
    

    【讨论】:

      【解决方案2】:

      可以是单个命令。

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

      【讨论】:

      • 您能解释一下 /s /q 和 /f 参数的作用吗?
      • @FranzDschler:在命令行上键入del /?,您会得到:/f = 强制删除只读文件。 /s = 从当前目录和所有子目录中删除指定文件。显示正在删除的文件的名称。 /q = 指定安静模式。系统不会提示您确认删除。
      猜你喜欢
      • 2011-03-14
      • 1970-01-01
      • 2011-09-18
      • 2018-09-05
      • 1970-01-01
      • 2019-10-18
      • 1970-01-01
      • 2013-01-04
      • 1970-01-01
      相关资源
      最近更新 更多