import osimport os.pathrootdir = os.getcwd() + "\..\..\sources"f = open("out.txt", "w")for parent,dirnames,filenames in os.walk(rootdir): for filename in filenames: if(filename.endswith(".h")): continue path=os.path.join(parent,filename) index=path.find('sources') path=path[index:] path=path.replace('\\','/') path='../../'+path+' \\' print path print >>f, pathf.close()os.system("pause")
python2.7
脚本是针对windows的,linux上直接使用find好了