• 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个文件。

  • 相关阅读:
    URL记录
    Mongodb集群节点故障恢复场景分析(转)
    IO 和 NIO 的区别
    VUE 前端项目优化方法
    缓存的穿透和雪崩
    接口如何处理重复请求?
    线程池构造类 ThreadPoolExecutor 的 5 个参数
    大型网站在架构上应当考虑哪些问题
    synchronized 和 lock 的区别
    JVM虚拟机 YGC和FGC发生的具体场景
  • 原文地址:https://www.cnblogs.com/hkmhd/p/9999457.html
Copyright © 2020-2023  润新知