提交 7f94e7d3 编写于 作者: W wizardforcel

2020-03-03 22:14:30

上级 fe098367
import os
import sys
from os import path
import subprocess as subp
max_sz = 100 * 1024 * 1024
def main():
dir = sys.argv[1]
files = map(lambda f: path.join(dir, f), os.listdir(dir))
files = list(filter(lambda f: path.getsize(f) <= max_sz, files))
zips = []
start = 0
total = 0
for i, f in enumerate(files):
sz = path.getsize(f)
if total + sz > max_sz:
zips.append(files[start:i])
start = i
total = sz
else:
total += sz
zips.append(files[start:])
print(len(zips))
for i, z in enumerate(zips):
subp.Popen(['7z', 'a', '-mx0', path.join(dir, f'{i}.7z'), *z])
if __name__ == '__main__': main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册