執(zhí)行下腳本可以將藍(lán)湖的切圖不同分辨率的切圖復(fù)制到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
#重寫(xiě)命源文件名稱
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("要復(fù)制的文件:" + desFile)
shutil.copyfile(newFile, desFile)
pass
def main():
copyFile()
pass
if __name__ == '__main__':
main()