Counting File types in dir and sub dir

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnberman
    New Member
    • Nov 2008
    • 1

    #1

    Counting File types in dir and sub dir

    Hi

    My first post so be gentle

    I want to count the number html and htm files in a dir and its sub dirs, i have found script that will do a simple count of all files but nothing else. Also recursing th ecound into the sub dirs does not seem easy ?

    Any help appreciated.

    John Berman
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi. Welcome!

    Check out the scandir function.
    That, coupled with the is_dir function should do the trick.

    You could simply create a function that scans a single directory, counting the files and return the count. If the function finds a directory, it would simply call itself again on that directory and add the return value of that call to the current count.

    Comment

    Working...