12345678910111213141516171819202122232425262728293031323334353637383940 |
- # -*- coding: utf-8
- import os
- import re
- import json
- import sys
- #root_dir_path = "../release/bytedancegame"
- root_dir_path = sys.argv[1]
- extern_name_list = [".json", ".ExportJson", ".ls", ".lh", ".lmat"]
- def removeBlankChar(filepath):
- f1 = open(filepath, "rb")
- content1 = f1.read()
- f1.close()
- content2 = re.sub("[*\\t\\n\\r]", "", content1) #"[\\s*\\t\\n\\r]"或"\s" (空格不去掉,以防命名中有空格)
- f2 = open(filepath, "wb")
- f2.write(content2)
- f2.close()
- print "remove blank char complete. file: %s" % filepath
- # end of removeBlankChar
- def removeBlankCharOfDir(dirpath):
- filename_list = os.listdir(dirpath)
- for filename in filename_list:
- filepath = dirpath + "/" + filename
- if os.path.isdir(filepath):
- removeBlankCharOfDir(filepath)
- else:
- for extern_name in extern_name_list:
- if filepath[-len(extern_name):] == extern_name:
- removeBlankChar(filepath)
- break
- # end of removeBlankCharOfDir
- removeBlankCharOfDir(root_dir_path)
- raw_input("\n\ndone! ....")
|