首页 > 解决方案 > 如何使用 Perl 拆分 zip 文件

问题描述

我有一个大小超过 1000MB 的 zip 文件。我想根据大小将其拆分为多个压缩的 zip 文件。如果每个拆分的 zip 文件大小为 10 MB,那就太好了。我的输入将是 zip 文件,输出应该是多个压缩的 zip 文件

#!/usr/bin/env perl 
  use strict;
 use utf8;
 use Archive::Zip qw(:ERROR_CODES :CONSTANTS);

  my $file = $ARGV[0];

 my $filesize = -s $file;
 print "Size: $filesize\n";

感谢您的帮助 谢谢

标签: perlzip

解决方案


You can use Splitted Zip for this.

Refer to https://www.perlmonks.org/bare/?node_id=534408

Its purpose is to arrange the files to be sent in order to produce multiple ZIP archives, each of which remains valid and self-contained.

You can also use "split-archive" functionality of "zip" itself

$ zip -r -s 10m file.zip directory/ => using the "--split-size" option.

推荐阅读