Text File:How to insert a word every x amount of lines?

I have a text document with 50 URL’s. 1 URL per line. How can I insert a specific keyword every X amount of lines. For example, I need to insert #BREAK# after every 5 lines? I have textpad, notetab pro (text editors) but cannot figure out how to do this? Appreciate any help! Thanks!
That was just an example. I have files with 100,000+ URL’s. I need to insert a keyword every x amount of lines. Cannot be done manually, looking for a macro or way to do this?

2 Responses to Text File:How to insert a word every x amount of lines?

  1. just open your text file and insert #break# every five lines.

    set TEXT WRAPping to off so you can see the URL in one line.

    Report Spam/Abuse

  2. It cannot be done automatically within a text editor, as there is no way for the test editor to count the lines, etc.
    One way would be to use a programming language where you can input the file with the urls, and go through the file placing the keyword after x amount of lines. The file is then output with these keywords.
    A quick c++ example.
    #include

    int main() {

    using namespace std;

    char cur_line[1000]; // assume line is no longer than 999 characters, the last character should be a null ‘’;
    int count = 1;
    while (cin.getline(cur_line, 1000)) {
    cout < < cur_line << 'n';
    if (count == 5) { // the fifth line
    cout << "#breakn"; // or whatever you want to include
    count = 1; // reset the count
    } else
    count++; // increment the count;
    }
    }

    if you compile this as insert.cpp, and have insert.exe, then call insert < > ,
    ie insert < index.html > index_2.html
    note, the files cannot be the same.

    Report Spam/Abuse

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>