最近公司代码需要做版权审查需要一些代码,足足60页的word文档,
如果一个一个文件的copy代码 就真是out,最近在学习python,就写了个python的脚本,方便上面操作。
__author__ = 'jghost' import os for root,dirs,files in os.walk('your source'): print root #path for name in files: if name.endswith('.java'): dic = open('/home/jghost/filefilter.txt','a') dic.write(' ') dic.write(' ') dic.write(name+' ') dic.write('#author:jgost ') dic.write('#company:xxxx ') source = open(root+'/'+name) while True: context = source.readline() if context.strip().startswith('#'): continue dic.write(context) if not context: break source.close() dic.close()