Inserting text into a file

Results 1 to 2 of 2

Thread: Inserting text into a file

  1. #1
    Join Date
    Dec 1969

    Default Inserting text into a file

    Hi,<BR><BR>I need to make a script that will, with one click, add a line of code (an include statement) to all asp files in a certain directory.<BR><BR>For example...<BR><BR>You have an input box on a form asking for the directory path.<BR>The user types C:/myaccount/thisdir and the script will then go through every .asp page in that directory and add &#060;!--#include File=""--&#062; to the first line in the file.<BR><BR>I can imagine this being quite a difficult task so your help is extremely appreciated!!!<BR><BR>Regards,<BR><BR>James Andrews<BR>

  2. #2
    jason Guest

    Default RE: Inserting text into a file

    It&#039s a bit involved for a reply, but it is actually very easy.<BR><BR>there are a couple of tutorials you&#039ll need to read first<BR><BR><BR><BR>read the one about nested loops<BR>read the one about creating a page counter<BR><BR>they&#039ll give you the knowledge you need to run through a directory full of files, open them and insert something in them. to insert i9t in the first line, you&#039ll need to store the filecontents in a variable, concatenate the include bit, then re-write the entire file.<BR><BR>jason<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts