批量重命名ios图片文件(android不能用@符号)

来源:互联网 发布:织梦返利系统源码 编辑:程序博客网 时间:2024/05/21 06:34
在开发中,设计提供的图片安装ios的图片规格提供,但是图片放到android资源目录后编译会出问题,所以需要重新命名图片,下面是python脚本来批量改图片名。

path指向的是你的原图片目录
destPath 指向的是你要生成的图片目录

#!/usr/bin/python
# coding=utf-8
import sys
import os
import shutil

path = 'D:\mypath\ios'
destPath = 'D:\mypath\android'

if os.path.exists(destPath):
    shutil.rmtree(destPath)
os.mkdir(destPath);

for f in os.listdir(path):
    if os.path.isfile(path + os.path.sep + f):
        print('' + f);
        newPath = destPath + os.path.sep + f.replace('@', '');
        print(newPath);

        shutil.copy(path + os.sep + f, newPath);


希望脚本能够给使用ios图片资源的android程序员提供一些方便。

0 0
原创粉丝点击