Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to Insert a Header Row in a Text File using a Batch program.  (Read 8445 times)

0 Members and 1 Guest are viewing this topic.

jpilch

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    How to Insert a Header Row in a Text File using a Batch program.
    « on: November 01, 2011, 01:03:35 PM »
    New to using this forum and batch files, so please bear with me.
    It doesn't seem like this would be hard, but I've search everywhere I can think of and can't find the answer.

    Using Windows 7

    Need to open text file, and add a static header. 

    Original Text File Example:
    XHD051500101103
    XHE   PO#1005
    XDT2496581 001
    XDT2670961 001
    XOE  27   33

    Need it to be:
    Header
    XHD051500101103
    XHE   PO#1005
    XDT2496581 001
    XDT2670961 001
    XOE  27   33

    Any help would be GREATLY appreciated.   :)


    gpl



      Apprentice
    • Thanked: 27
      Re: How to Insert a Header Row in a Text File using a Batch program.
      « Reply #1 on: November 01, 2011, 01:47:38 PM »
      With a little lateral thinking, try this

      Code: [Select]
      >{dummy}.txt echo Header
      >>{dummy}.txt type "Original Text File"
      del "Original Text File"
      ren {dummy}.txt "Original Text File"

      simply put, create a new file with the header in
      append the content of your main file
      delete the main file
      rename the temp file to the original main file name