First time here? Check out the Help page!
1 | initial version |
If you're just combining text files together, the simplest method, especially if you're already using Python, is just to use a Python script that merges text files. This one will merge all .idf files in the directory (including subfolders) into a single file called merge.idf. Just copy the script into whatever directory in which you want to combine all the IDFs.
# This script copies all .idf files in dir and writes them into a new file called merge.idf
import os
dir = os.path.dirname(os.path.realpath(__file__))
mereged_text = ""
for path, subdirs, files in os.walk(dir):
for name in files:
ext = os.path.splitext(name)[-1].lower()
if ext == ".idf":
with open(name) as fp:
text = fp.read()
mereged_text += text
mereged_text += "\n" # if new line is desired
with open ('merge.idf', 'w') as fp:
fp.write(mereged_text)