Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Anarchy99

macrumors 65816
Original poster
Dec 13, 2003
1,041
1,034
CA
i have book and its in a single text file
i want it to be broken up by chapters
i was wondering if there was software or maybe a applescript or something that when it sees chapter 2
it will make a new file till chapter 3 etc
 
What format is the file currently in? Text file could be plain text, rich text, MS Word, etc.

For plain text, if you're not afraid of the command line you can look at the csplit command (do man csplit for info), or if you want to get really geeky, I'm sure awk can do it.

Example of csplit
Code:
csplit -f Chapter_ -ks book.txt '/^Chapter/' {25}
The 25 at the end designates how many chapters there are. You can set it higher than you need to be sure it gets them all, though it will output an error message in Terminal, but all of the files will be split.
 
What format is the file currently in? Text file could be plain text, rich text, MS Word, etc.

For plain text, if you're not afraid of the command line you can look at the csplit command (do man csplit for info), or if you want to get really geeky, I'm sure awk can do it.

Example of csplit
Code:
csplit -f Chapter_ -ks book.txt '/^Chapter/' {25}
The 25 at the end designates how many chapters there are. You can set it higher than you need to be sure it gets them all, though it will output an error message in Terminal, but all of the files will be split.

cool did csplit took a little bit of changing but nothing i couldnt look up

thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.