抽离项目工程中图片2X 3x

!/usr/bin/env python

-- coding:utf-8 --

@Author : yumingquan

python 脚本

import shutil,os,sys

def get_dir(path,fileType):
    #查看当前目录文件列表(包含文件夹)
    allfilelist = os.listdir(path)
    for file in allfilelist:
        filepath = os.path.join(path, file)
        #判断是否是文件夹,如果是则递归遍历
        if os.path.isdir(filepath):
            get_dir(filepath,'x.png')
        else:
            if filepath.endswith(fileType):
                copyPath = filepath.replace(targetPath,distPath)
                copyDir = os.path.dirname(copyPath)
                if not os.path.exists(copyDir):
                    os.makedirs(copyDir)
                shutil.move(filepath, copyPath)


if __name__ == '__main__':
    targetPath = sys.argv[1]
    distPath = os.getcwd()
    get_dir(targetPath,'x.png')
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容