修改Assets下目录的图片文件资源,代码中图片引用有拼接图片名称情况,需单独修改
import os
#文件前缀
filename_prefix = 'XXXX'
#文件后缀
filename_suffix = 'XXXX'
target_url = '/Users/HOSTNAME/work/PROJECTNAME/PROJECTNAME/PROJECTNAME/PROJECTNAME/Assets.xcassets/Appoint'
def verify_filename(file_name):
if file_name.endswith('.png') or file_name.endswith('.jpg'):
return True
return False
#遍历文件,符合规则的进行重命名
for (root, dirs, files) in os.walk(target_url):
print('-----------')
if len(files) == 2 :
for file_name in files:
if verify_filename(file_name):
# 1.修改文件夹 xxx.imageset --> filename_prefix + 'xxx' + filename_suffix +'.imageset'
file_path = os.path.join(root, file_name)
fold_oldpath = file_path[:(len(file_path) - len(file_name) - 1)]
fold_oldname = os.path.splitext(fo