执行下脚本可以将蓝湖的切图不同分辨率的切图复制到android不同mipmap分辨率下
import os.path
import shutil
def copyFile():
srcDir = "C:\\Users\\Administrator\\Downloads\\"
srcDir += "guide_3_slices (1)"
srcName = "guide_three.png"
desDir = "D:\\code\\android_vip\\android\\app\src\main\\res"
# desDir = "D:\\test"
files = ["mipmap-mdpi", "mipmap-hdpi", "mipmap-xhdpi", "mipmap-xxhdpi", "mipmap-xxxhdpi"]
srcFiles = [os.path.join(srcDir, file) for file in files]
# print(files)
# print(desFiles)
# print(srcFiles)
for srcDir in srcFiles:
if not os.path.exists(srcDir):
continue
path = os.path.split(srcDir)[1]
files = os.listdir(srcDir)
fileDirs = [os.path.join(srcDir, file) for file in files]
for file in fileDirs:
if not file.endswith(".png"):
continue
#重写命源文件名称
newFile = os.path.join(srcDir, srcName)
os.renames(file, newFile)
#目的文件
desPath = os.path.join(desDir, path)
print(desPath)
print(os.path.exists(desPath))
if not os.path.exists(desPath):
os.makedirs(desPath)
desFile = os.path.join(desPath, srcName)
# print(desFile)
print("原始文件:" + newFile)
print("要复制的文件:" + desFile)
shutil.copyfile(newFile, desFile)
pass
def main():
copyFile()
pass
if __name__ == '__main__':
main()
网友评论