
Combine chapter text files into one numbered file per book
Source:R/combine_book_files.R
combine_book_files.RdTakes chapter files named like 1_howcanyou.txt and 2_howcanyou.txt,
groups them by the shared title stem after the underscore, orders chapters
by their numeric prefix, and writes one combined .txt file per group
using filenames like 1_howcanyou.txt.
Usage
combine_book_files(
input_dir,
output_dir = file.path(input_dir, "combined"),
separator = "\n\n",
overwrite = FALSE
)Arguments
- input_dir
Character scalar. Folder containing chapter
.txtfiles.- output_dir
Character scalar. Folder where combined
.txtfiles should be written. Defaults to acombined/subfolder insideinput_dir.- separator
Character scalar. Text inserted between chapters when combining them. Defaults to two line breaks.
- overwrite
Logical scalar. If
TRUE, replace existing output files. Defaults toFALSE.