批量修改iOS工程目录文件名
import os
#文件前缀
filename_prefix = 'HEADER'
#文件后缀
filename_suffix = 'SUFFIX'
#需要更新文件目录
target_path = '/Users/HOSTNAME/demo/PROJECTNAME/PROJECTNAME'
#需要查询文件目录
project_path = '/Users/HOSTNAME/demo/PROJECTNAME/PROJECTNAME/Sections'
#工程文件地址
pbxpro_path = '/Users/HOSTNAME/demo/PROJECTNAME/PROJECTNAME.xcodeproj/project.pbxproj'
#文件重命名函数,返回新的文件名
def file_rename(file_path):
print(file_path)
root_path = os.path.split(file_path)[0] # 文件目录
root_name = os.path.split(file_path)[1] # 文件名包含扩展名
filename = os.path.splitext(root_name)[0] # 文件名
filetype = os.path.splitext(root_name)[1] # 文件扩展名
filename_new = filename
if filename.startswith(filename_prefix) == False:
filename_new = filename_prefix + filename_new
if filename.encode(filename_suffix) == False:
file