开发者

Zip - Add files and folders that are newer, remove old ones

I want to do the following on a Windows and Linux machine :

  • Zip several folders in an automated process

  • Add new files to archive, remove old ones.

I've experimented with .bat and .sh scripts using 7zip and have come across some limitations (not easy to update/remove from existing archive, Linux wants folders in .tar form first).

I have decided to write a Java application that will do the decision making (is archive out of date), and will call 7zip to compress the files.

I am thing of the following pseudo-code:

Get modified date of archive
Get latest modified date of files within folder
If latest modified date is later that archive date
    Delete archive
    Create new archive

There will seve开发者_如何学运维ral archives within a folder hierarchy, so if a folder is needed to be updated this will cut the processing down.

Sound good? Or is there another, simpler method around?


I would suggest you use java.util.zip instead of 7zip if you really want to do this in Java.

A better solution might be to do 7z -u and then play around with the options.

http://sevenzip.sourceforge.jp/chm/cmdline/switches/update.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜