#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Location
    New York
    Posts
    89
    Rep Power
    14

    Reading a directory


    I am trying to simply convert a bunch on .txt files to .html files by pasting a header and footer to the txt file content and resaving as .html.

    I wrote a script in PHP to do it, but with 28,000 files to convert it would be a fairly lengthly task to ftp all the files up and then back down.

    I have read how to open and save a file, but is it possible to read and loop through a directory of files?

    sorry total newbie question..

    rootdog
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,626
    Rep Power
    4247
    If you're using a *NIX machine, then you'd typically use opendir, readdir and closedir. I posted an example of how to use these functions a while back in this thread:

    Trying to compile/run a program i wrote on a UNIX machine, on a Linux machine.

IMN logo majestic logo threadwatch logo seochat tools logo