anyone know software to split a text file

Discussion in 'Mac Apps and Mac App Store' started by Anarchy99, Feb 24, 2010.

  1. Anarchy99 macrumors 6502

    Joined:
    Dec 13, 2003
    #1
    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
     
  2. miles01110 macrumors Core

    miles01110

    Joined:
    Jul 24, 2006
    Location:
    The Ivory Tower (I'm not coming down)
    #2
    You could write a small script to do this , but if it's just one text file I'd just do it manually. Look up TextWrangler, it has a "Find" feature you can use.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    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.
     
  4. Anarchy99 thread starter macrumors 6502

    Joined:
    Dec 13, 2003
    #4
    cool did csplit took a little bit of changing but nothing i couldnt look up

    thanks
     

Share This Page