zoukankan      html  css  js  c++  java
  • 7z.exe 命令行压缩文件排除文件(exclude filenames) 手记

    命令行使用格式:Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...][<@listfiles...>]

     1 <Commands>
     2   a : Add files to archive
     3   b : Benchmark
     4   d : Delete files from archive
     5   e : Extract files from archive (without using directory names)
     6   h : Calculate hash values for files
     7   i : Show information about supported formats
     8   l : List contents of archive
     9   rn : Rename files in archive
    10   t : Test integrity of archive
    11   u : Update files to archive
    12   x : eXtract files with full paths

    [<switches>...]:压缩文件排除选项

    -x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
    
    -r[-|0] : Recurse subdirectories

    -x 选项排除文件,-xr 选项可以遍历子目录,排除子目录中的文件

    如果不使用 r 选项,子目录的文件则必须使用完整的目录路径进行排除(见 listfile 其它用法中的解释)。


    例子

    7z a -xr"!descript.ion" newFile "c:program files7-zip"

    压缩时,可以排除子目录中包含有 descript.ion 这个文件,! 感叹号为通配符开关,必须添加。

    如果需要排除多个文件,需要使用多个 -x ,推荐进阶用法,使用列表文件。


    进阶用法(列表文件)

    将需要排除的文件,使用文本保存,应用这个列表中的文件,在列表中可以直接使用通配符,而不需要添加感叹号。

    如exclude.txt:

    *.exe
    *.txt

    例子:

    7z a -xr"@exclude.txt" newFile "c:program files7-zip"

    压缩时,可以排除所有的 txt、exe 文件。


    listfile 的用法

    如果不使用 r 选项,listfile 中需要排除子目录的文件,则必须为完整的路径。

    例如 C:program fies7-ziplang 这个子目录,需要排除 txt 文件,则 listfile 写法为

    *lang*.txt

    关于通配符的使用

    通配符有 2 种,“* 号”与“? 号”

    * 号可以匹配任意数量的任意字符

    ? 可以匹配单个数量的任意字符

    如文件名 zh-cn.txt 、zh-tw.txt

    zh-*.txt 可以匹配这2个文件。

    zh-c?.txt 只能匹配zh-cn.txt 这个文件。

    zh-??.txt 可以匹配这2个文件。

  • 相关阅读:
    Java学习10.22(Javaweb对输入信息进行验证——常用的方法)
    mysql with python
    Linux
    Python 基础的一些习题
    Python 推导式、迭代器、生成器、模块和包
    Python 文件操作、异常
    Python 部分内置函数、作用域、闭包、递归
    Python 基础函数、解包
    Python 条件与循环
    Python 集合、字典、运算符
  • 原文地址:https://www.cnblogs.com/hkmhd/p/9999457.html
Copyright © 2011-2022 走看看