creatJsonProfile.py 782 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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('.'))