如果一个一个文件的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('\n')
dic.write('\n')
dic.write(name+'\n')
dic.write('#author:jgost\n')
dic.write('#company:xxxx\n')
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()