# -*- coding: utf-8 -*-
#!/bin/python
import os
import sys
def TransCode(rootpath, pattern):
for root, dirs, files in os.walk(rootpath):
for file_ in files:
if file_.endswith("m"):
file_name = os.path.join(root, file_)
dst = 'result/' + root
if pattern == 'windows':
os.system('mkdir -p ' + dst)
os.system('iconv ' + file_name + ' -f utf8 -t gbk -c -s > ' + dst + '/' + file_)
elif pattern == 'linux':
os.system('mkdir -p ' + dst)
os.system('iconv ' + file_name + ' -f gbk -t utf8 -c -s > ' + dst + '/' + file_)
else:
print 'error type'
exit(1)
if __name__ == '__main__':
print sys.argv[0]
print sys.argv[1]
print sys.argv[2]
TransCode(*sys.argv[1:3])
exit(0) python
usage: python XXX.py rootpath to_platform
linux