some scripts or PHP functions to deal with directories.
you can click on every built-in PHP function in the code to see the PHP manual entry for that function.

choose the function or script you need from the category “directories”

directory list with exec (download)

using exec() to produce a directory listing. probably the shortest code to produce a full file-list without resorting to the servers built in directory display

htaccess 2 (download)

put this in your PHP file without extension (see htaccess snippet) to get to your $_GET variables

htaccess (download)

put this on an .htaccess file and drop it in any directory. with this you can force any filename to be recognized as PHP

human readable size (download - demonstration)

to give a user the size of his account (or the admin the size of the users folder) in a more human readable format, you can use this PHP function. it will scan the directory recursively and return the value in kilobytes, megabytes so its easier to read.

read dir and list (download)

read and list directory function with filter option. returns only directories which match a prefix filter.

recursive directory delete (download)

delete directory recursively. loops through a directory and attempts to delete everything inside the directory before removing the directory itself. WARNING - once you started this function it's done - no way to recover deleted files. think twice before trying this out !

recursive directory listing (download)

a function to scan directories recursively and save the result to an array with informations like level, path, name and file informations. you can optionally set a filter to return only files wich match the filter as extension.

recursive make directory (download)

a PHP function to create directories recursively. simply call this function with a path and it will attempt to create all missing directories recursively. returns array with verbose report.

directory structure to list (download)

this PHP function displays any given directory structure as recursive list. it even outputs nice HTML markup code with indenting.

see also PHP Classes for dealing with files and directories