7zip CLI 白名单文件以通过扩展添加

7zip CLI whitelist files to add by extension

如果我运行正在使用 7z a -tzip myDestFile.zip some/dir 命令并且我想向它添加一个文件扩展名白名单,这样如果我把 *. txt *.xls *.doc,它只会将具有这些扩展名的文件添加到存档中,我该怎么做?该文档在通过单个扩展名将白名单列入白名单方面做得很好,但是多个呢?我是否只需要 运行 在我的脚本中多次执行该命令?

我试过以下方法:

7za a -tzip test.zip ./subdir *.txt *.xlsx # throws error
7za a -tzip test.zip ./subdir -i!./*.txt -i!./*.xlsx # also results in error
7za a -tzip test.zip ./subdir -i!*.txt -i!*.xlsx # also results in error

这个问题不应该一直悬而未决。对我有用的答案如下:

7za a -tzip test.zip ./*.txt ./*.xlsx