Using PHP offline to manipulate text files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anonymous

    Using PHP offline to manipulate text files

    I need to create an application that will do fairly simple text manipulation
    on 20,000 files in text format (html files). The files exist both on my
    Windows machine and on a FreeBSD server. I prefer to do the manipulation on
    my machine where it's easier to create backup copies, recover from
    programming errors and so on, then upload the files to the server. All I'm
    doing is extracting certain elements from each file and creating a different
    file with the same content that will look better. I could do this in
    FrontPage (or even Notepad) if I didn't have 20,000 files, so I need to
    write an application that go through each file in a directory, open it,
    locate the relevant text elements and create a new file that has these text
    elements in an appropriate format.

    I'm comfortable that I can write an application like this in PHP, even
    though I do not have PHP installed on my computer, which is a Windows box
    and is not being used as a server. Does this make sense? Can I install and
    use PHP for this purpose without lots of server-related baggage? Any
    pointers on using PHP this way?

    TIA


  • Richard T. Cunningham

    #2
    Re: Using PHP offline to manipulate text files

    Without the server-related baggage means you'll be limited to the CLI
    version of PHP (which will run from any batch file for any DOS in
    Windows including XP). I wrote a simple script myself that works under
    the CLI version to clean multiple mailboxes in a mail directory.
    You're more than welcome to it, if CLI is the route you take.

    Richard

    On Sun, 14 Dec 2003 13:25:19 -0600, "Anonymous" <anon@fairmark. com>
    wrote:
    [color=blue]
    >I need to create an application that will do fairly simple text manipulation
    >on 20,000 files in text format (html files). The files exist both on my
    >Windows machine and on a FreeBSD server. I prefer to do the manipulation on
    >my machine where it's easier to create backup copies, recover from
    >programming errors and so on, then upload the files to the server. All I'm
    >doing is extracting certain elements from each file and creating a different
    >file with the same content that will look better. I could do this in
    >FrontPage (or even Notepad) if I didn't have 20,000 files, so I need to
    >write an application that go through each file in a directory, open it,
    >locate the relevant text elements and create a new file that has these text
    >elements in an appropriate format.
    >
    >I'm comfortable that I can write an application like this in PHP, even
    >though I do not have PHP installed on my computer, which is a Windows box
    >and is not being used as a server. Does this make sense? Can I install and
    >use PHP for this purpose without lots of server-related baggage? Any
    >pointers on using PHP this way?
    >
    >TIA
    >[/color]

    Comment

    • Ron

      #3
      Re: Using PHP offline to manipulate text files

      On Sun, 14 Dec 2003 13:25:19 -0600, "Anonymous" <anon@fairmark. com>
      wrote:
      [color=blue]
      >I need to create an application that will do fairly simple text manipulation
      >on 20,000 files in text format (html files). The files exist both on my
      >Windows machine and on a FreeBSD server. I prefer to do the manipulation on
      >my machine where it's easier to create backup copies, recover from
      >programming errors and so on, then upload the files to the server. All I'm
      >doing is extracting certain elements from each file and creating a different
      >file with the same content that will look better. I could do this in
      >FrontPage (or even Notepad) if I didn't have 20,000 files, so I need to
      >write an application that go through each file in a directory, open it,
      >locate the relevant text elements and create a new file that has these text
      >elements in an appropriate format.
      >
      >I'm comfortable that I can write an application like this in PHP, even
      >though I do not have PHP installed on my computer, which is a Windows box
      >and is not being used as a server. Does this make sense? Can I install and
      >use PHP for this purpose without lots of server-related baggage? Any
      >pointers on using PHP this way?
      >
      >TIA
      >[/color]
      If you are doing a search and replace why not use Dreamweaver? It's
      definitely in the full version and maybe in a trial version but it
      lets you do a find and replace in all files in the same folder. I've
      done it with 500 files but I'm not sure with 20000. Good luck.

      thx..ron

      Comment

      • Anonymous

        #4
        Re: Using PHP offline to manipulate text files

        > If you are doing a search and replace why not use Dreamweaver? It's[color=blue]
        > definitely in the full version and maybe in a trial version but it
        > lets you do a find and replace in all files in the same folder. I've
        > done it with 500 files but I'm not sure with 20000. Good luck.[/color]

        I think I need something more powerful than multi-file search and replace
        because I'm actually extracting several key elements from each of the
        existing pages and creating a new page in an entirely different format
        containing those elements. I could play with this concept, but it seems more
        straightforward to write a little application that opens each file, extracts
        the necessary information into a half-dozen variables, then writes a new
        file to replace the old one.


        Comment

        Working...