Title: Count files
Last modified: August 31, 2016

---

# Count files

 *  [snamyar](https://wordpress.org/support/users/snamyar/)
 * (@snamyar)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/count-files/)
 * Is there a way to display the number of files that are going to be listed in 
   a table?
    For instance, my shortcode is pointing to a folder to list all word
   documents in that folder. I would like to see the number of files somewhere in
   the page like table header.
 * [https://wordpress.org/plugins/file-away/](https://wordpress.org/plugins/file-away/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/count-files/#post-7207755)
 * Not currently a feature.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/count-files/#post-7207756)
 * If it’s urgent you can create some custom javascript to count your table rows
   and add the total to the page.
 *  [guess350](https://wordpress.org/support/users/guess350/)
 * (@guess350)
 * [10 years ago](https://wordpress.org/support/topic/count-files/#post-7208066)
 * – install “Allow PHP in Posts and Pages” plugin.
 * working code:
    ———————————————————————– $directory = “./upload2/” . $current_user-
   >user_login; // dir location $files = scandir($directory); for($i = 0 ; $i < 
   count($files) ; $i++){ if($files[$i] !=’.’ && $files[$i] !=’..’) { //echo $files[
   $i]; echo ““; $file_new[] = $files[$i]; } } $num_files = count($file_new)-1; //
   omit index.php echo (‘File Count: ‘ . $num_files ); // Prints the count ———————————————————————–
 * good luck.
 *  Plugin Author [thomstark](https://wordpress.org/support/users/thomstark/)
 * (@thomstark)
 * [10 years ago](https://wordpress.org/support/topic/count-files/#post-7208067)
 * Guess350, that code isn’t going to account for File Away’s many filtering options.
   The file count will not match the number of files ouput to the page under an 
   unlimited number of possible scenarios. It also doesn’t account for file away’s
   recursive directory iteration or directory tree navigation.
 *  [guess350](https://wordpress.org/support/users/guess350/)
 * (@guess350)
 * [10 years ago](https://wordpress.org/support/topic/count-files/#post-7208069)
 * for my case, i don’t allow user to create sub folders.
    i asked users to use 
   zip file instead for multiple files/sub folders. my main purpose is to provide
   quick file exchange without too much complex interface.
 * but, maybe one of the php experts may be able to come up with a better code to
   handle recursive directory.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Count files’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/file-away_e3e2e1.svg)
 * [File Away](https://wordpress.org/plugins/file-away/)
 * [Support Threads](https://wordpress.org/support/plugin/file-away/)
 * [Active Topics](https://wordpress.org/support/plugin/file-away/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/file-away/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/file-away/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [guess350](https://wordpress.org/support/users/guess350/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/count-files/#post-7208069)
 * Status: not resolved