import os import json def file_name(file_dir): fileList =["bg_kuang", "bg_kuang2", "bg_light"] f = open('filename.txt', 'w'); blank = False for root, dirs, files in os.walk(file_dir): for fileName in files: if root.split("\\")[-1]=="frame" or root.split("\\")[-1]=="sound" or root.split("\\")[-1]=="play" or (root.split("\\")[-1] in fileList): blank = True if root.split("\\")[-1] != "play": f.write("'" + fileName.split(".")[0] + "': 'assets/play/" + root.split("\\")[-1] + "/" + fileName + "',\n") else: f.write("'" + fileName.split(".")[0] + "': 'assets/" + root.split("\\")[-1] + "/" + fileName + "',\n") if blank: f.write("\n") blank = False f.close() fileList = file_name(os.path.abspath('.'))