import os import glob def file_to_string(f): text = "" with open(f, 'r') as n: text = n.read() n.close() return text def fill_text(f): return file_to_string(f) #file_to_string('res/head.txt') + file_to_string(f) + file_to_string('res/tail.txt') def create_files(files, directory): for f in files: print(f) n = open(directory + '/' + os.path.basename(f), "w") n.write(fill_text(f)) n.close() def collect_raw(d): return glob.glob(d) def clear_articles(): files = glob.glob('../*') print(files) if '../raw' in files: files.remove('../raw') for f in files: os.remove(f) def main(): clear_articles() create_files(collect_raw('entries/*'), '..') ## Start Program ## main()