Created
July 8, 2015 13:40
-
-
Save g2384/1095495d98f8a30305ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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