zst*_*eve 8 command-line archiving 7-zip
我正在(尝试)开发一个程序来通过 ShellExecute() 操作 7-zip 控制台程序 (7z.exe) 并将其传递给计算机生成的文件列表。
现在我想做的是:
我想向它传递一个命令行,告诉它包含和排除文件:即
include these :
c:\path\path2\path
c:\path\path2\path__\
.... more files
exclude these :
c:\path\path2\path\data\files\foo\bar\fish.dat
c:\path\path2\path__\data\slug.mp3
.... more files
Run Code Online (Sandbox Code Playgroud)
所以我做了一个这样的命令行:
7z a -t7z -i!"...file to include" -x!"file to exclude" ... etc etc
Run Code Online (Sandbox Code Playgroud)
我只是从记忆中重复,所以我知道命令行可能不准确
但是我输入的不起作用。我只是在 path 和 path__ 中获取所有内容。我想要的是一个里面看起来像这样的档案:
.\
path\
data\
files\
foo\
bar\
<everything in path\data\files\foo\bar except for foo.dat>
path__\
data\
<everything in path__\data\ except for slug.mp3>
Run Code Online (Sandbox Code Playgroud)
我能帮我得到这个结果吗?谢谢
不知道你的确切7z-command 它只是猜测,但它是这样的:
7z a -t7z -ir@"files_to_include.txt" -xr@"files_to_exclude.txt" ....
注意rafter-i和-xfor 递归。您也可能@在文件名之前使用而不是!. (或者至少你应该。!用于在命令行指定通配符:)
然后为您的files_to_exclude.txt内容。我相信你应该在这里使用相对路径。所以不要c:\....在你的路径之前指定。如果包含中的常用路径是c:\path\path2您需要从排除中删除它。这样做的原因是,在7z压缩文件时,它已经c:\path\path2去掉了-part(因为没有存储整个路径,只存储了相对部分)。所以你的排除不再匹配。您可以看到这一点,因为打开 .zip 时c:\path\path2不在 .zip 中。(所以匹配它不起作用)
所以你files_to_exclude.txt应该是这样的:
path\data\files\foo\bar\fish.dat
path__\data\slug.mp3
.... more files
Run Code Online (Sandbox Code Playgroud)
因此,如果在添加rafter-i和-x更改新的之后files_to_exclude.txt您仍然遇到麻烦,我们需要查看您的实际命令。
| 归档时间: |
|
| 查看次数: |
18238 次 |
| 最近记录: |