Script that can list files

Discussion in 'Programming' started by digitalballer, Jul 31, 2008.

  1. #1
    Is there a script or an application that can take all the files in a directory and export them to a list in a txt file? Or would it be possible to do that with a common program like excel? If so, how?

    Your advice is appreciated
     
    digitalballer, Jul 31, 2008 IP
  2. jack_ss

    jack_ss Guest

    Messages:
    94
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In PHP:
    <?
    $d = dir("./path_to_dir");
    while (false !== ($f = $d->read())) $p .= $f."\n";
    file_put_contents("files.txt", $p);
    $d->close();
    ?>
    PHP:
    If you don't have PHP 5 use the following instead of file_put_contents:
    
    $fp = fopen("files.txt", "w");
    fwrite($fp, $p);
    fclose($fp);
    
    PHP:
    Enjoy.
     
    jack_ss, Jul 31, 2008 IP