简体   繁体   English

使用命令行将zip文件从一个存档添加到另一个存档

[英]Add zip files from one archive to another using command line

I have two zip archives. 我有两个zip档案。 Say, set1 has 10 csv files created using Mac OS X 10.5.8 compress option, and set2 has 4 csv files similarly created. 假设set1有10个使用Mac OS X 10.5.8 compress选项创建的csv文件, set2有4个类似创建的csv文件。 I want to take the 4 files from zipped archive set2 and add them to list of files in archive set1 . 我想从压缩存档set2提取4个文件,并将它们添加到存档set1中的文件列表中。 Is there a way I can do that? 有没有办法可以做到这一点?

I tried the following in Terminal: 我在终端机中尝试了以下方法:

zip set1.zip set2.zip

This adds the whole archive set2.zip to set1.zip , ie, in set1.zip now I have: 这将整个存档set2.zip添加到set1.zip ,即在set1.zip我现在有:

file1.csv, file2.csv,..., file10.csv, set2.zip

What I instead want is: 我想要的是:

file1.csv, file2.csv,..., file10.csv, file11.csv, ..., file14.csv

where, set2.zip is the archive containing file11.csv, ..., file14.csv . 其中, set2.zip是包含file11.csv, ..., file14.csv的存档。

Thanks. 谢谢。

我不知道内置的OS X工具,但是有一个zipmerge实用程序作为libzip包的一部分(可用的hg存储库 )。

unzip set2.zip -d .tmpdir; cd .tmpdir; zip ../set1.zip *; cd ..; rm -r .tmpdir;

This script here should do it. 这个脚本应该在这里做。

zipjoin.sh zipjoin.sh

#!/bin/bash
#Example: ./zipjoin.sh merge_into.zip merge_from.zip
mkdir .tmp
unzip $2 -d .tmp
zip $1 .tmp/*
rm -r .tmp

Hope that helps! 希望有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM