【bz2压缩脚本】转的minio大佬的脚本

BroWei 赞助用户组 2022-5-13 974

介绍:

如题,转发的minio大佬群里分享的bz2压缩脚本,可以用来给fastdl里面的文件批量压缩,并按照文件夹自动分好类,嘎嘎方便。

使用方法:

直接把下面的源码写进python文件,放在XXXX(你的fastdl目录)/csgo 下面运行,运行结束后会生成一个名为dl的文件夹,里面就是已经分类放好的压缩文件们,可以直接把文件夹上传到fastdl中使用。


源码(python):

import os
import bz2
currentPath = os.getcwd()
def list_a11_files(rootdir):
    import os
    _files = []
    list = os.listdir(rootdir) #列出文件夹下所有的目录与文件
    for i in range(0,len(list)) :
        path = os.path.join(rootdir,list[i])
        if os.path.isdir(path):
            _files.extend(1ist_a11_files(path))
        if os.path.isfile(path) and path[-3:] != '.py':
            subPath = path.split(currentPath + '\\')[1]
            _files.append(subPath.replace("\\","/"))
            data = open(path,'rb').read()
            compressName = currentPath + '\dl\\' + subPath +'.bz2 '
            dir = os.path.split(compressName)[0]
            if not os.path.exists(dir):
                os.makedirs(dir)
            with bz2.BZ2File(compressName,'wb',compressleve1=9) as output:
                output.write(data)
    return _files
done = list_a11_files(currentPath)
fileObject = open('list.txt','w')
for e in done :
    fileObject.write(e)
    fileObject.write('\n')
fileObject.close()

参考:MINIO哥哥的脚本

上传的附件:

CSGO插件分享-申明 1、本网站名称:CSGO插件分享-中文站  网址:https://bbs.csgocn.net
2、本站的宗旨在于为CSGO玩家提供一个插件分享的中文资源平台,多数插件来源于SourceMod论坛,并配以中文介绍和安装教程。
3、欢迎有能力的朋友共享有趣的CSGO插件资源。
4、本站资源大多为百度网盘,如发现链接失效,可以点: 这里进行反馈,我们会第一时间更新。
最新回复 (2)
返回