This will list all files in a directory
$handle=opendir('.');
echo "Directory handle: $handle\n";
echo "Files:\n<br>";
while ($file = readdir($handle)) {
echo "$file\n<br>";
}
closedir($handle);
It wouldnt be too hard to check what file type it is (in the while loop) and add a counter.
Hope its what you want
Pryce