1
0

txtmerge.py 557 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. # usage: txtmerge.py <input_dir> <output_file_name>
  3. # does the exact opposite of txtsplit.py
  4. import os
  5. import sys
  6. import re
  7. import io
  8. assert len(sys.argv) == 3, "usage:\ntxtmerge.py <input_dir> <output_file_name>"
  9. idir = str(sys.argv[1])
  10. oname = str(sys.argv[2])
  11. ofile = io.open(oname, 'w', encoding='utf-16', newline='\r\n')
  12. for iname in sorted(os.listdir( idir )):
  13. ifile = io.open(os.path.join(idir,iname), 'rt', encoding='utf-8')
  14. text = ifile.read()
  15. ofile.write(text)
  16. ifile.close()
  17. ofile.close()