Skip to content

Instantly share code, notes, and snippets.

@g2384
Created July 8, 2015 13:40
Show Gist options
  • Save g2384/1095495d98f8a30305ac to your computer and use it in GitHub Desktop.
Save g2384/1095495d98f8a30305ac to your computer and use it in GitHub Desktop.
import os
path = "C:\downloads"
keyword=".cl"
merged_file_name="merged_file"+keyword
def backtrace(path, l, content, suffix):
for i in l:
path_i=path+"\\"+i
print path_i
if os.path.isdir(path_i):
content = backtrace(path_i, os.listdir(path_i), content, keyword)
if os.path.isfile(path_i):
if i.find(keyword)>0 and i!=merged_file_name:
with open(path_i, 'r') as content_file:
# change the style of merged string
content += "\n\n\n=======\n"+path_i+"\n=======\n"
content += content_file.read()
return content
content=backtrace(path, os.listdir(path), "", keyword)
f = open(merged_file_name, 'w')
f.write(content)
print "finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment