直接上代码 :
《慎-重-使-用,小-心-毁-盘》
import os
def tips(text):
print("[-"+text+"-]")
def Get_Res_All_File_Name(Res_dir):
All_File_Names = []
All_File_Path = []
for root, dirs, files in os.walk(Res_dir):
for file in files:
root = str(root).replace("\\","/")
All_File_Path.append(root+"/"+file)
file = str(file)
file_index = file.find(".")
if file_index != -1 :
file_name = file[0:file_index]
All_File_Names.append(file_name)
else:
All_File_Names.append(file)
return All_File_Names,All_File_Path
def Rename_All(All_File_Names , All_File_Path , Name_Add_Prefix):
Count = 0
for names in All_File_Path:
new_name = names.replace(All_File_Names[Count],Name_Add_Prefix+All_File_Names[Count])
os.rename(names,new_name)
Count += 1
def Edit_All_Xml_Name(Poject_dir , Name_Add_Prefix):
Res_dir = Poject_dir + "/res"
All_File_Names , All_File_Path = Get_Res_All_File_Name(Res_dir)
Rename_All(All_File_Names , All_File_Path , Name_Add_Prefix)