Thanks All (Especially Warren); Final Code: function dirList ($directory) { $results = array(); $handler = opendir($directory); while ($file = readdir($handler)) { if ($file != '.' && $file != '..') $results[] = $file; } closedir($handler); return $results; } $origin = "pathto/images/"; #load file listing into an array $shell = shell_exec("du $origin"); $array = array_reverse(explode("\n",$shell)); $contIdArr = array(); $newArr = array(); foreach($array as $elem){ $newDir = ""; $pathArray = explode("/", $elem); $nodeDepth = count($pathArray); for($count=1; $count<$nodeDepth; $count++){ $newDir = $newDir.$pathArray[$count].'/'; } $newArr[] = '/'.$newDir; } sort($newArr); foreach($newArr as $dir){ $pathArray = explode("/", $dir); $fileListArr = dirList($dir); } $db = mysql_connect("localhost","usr","pwd"); mysql_select_db("db",$db); foreach($fileListArr AS $value) { $sql="INSERT INTO r2 (ID, RECORDING) VALUES('','$value')"; $result = mysql_query($sql) or die (mysql_error()); } --- Rahul Sitaram Johari Founder, Internet Architects Group, Inc. [Email] sleepwalker@xxxxxxxxxxxxxxxx [Web] http://www.rahulsjohari.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php