944,116 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 560
  • PHP RSS
Nov 10th, 2009
0

Count Files in Server

Expand Post »
Dear All,
I am developing a Lease Management System and I have Stored LEase agreements in Folder Named LAPO
I used ID for search.
and in LAPO Folder I have created folders name like 9624
inside 9624, I have stored LA.pdf
There are 2300 folders in LAPO
and 95% of the Folders have LA inside.
1. I want to count these LA.pdf through PHP command or function.
Thanks.
2. Also I want the folder name in which LA.pdf exists.
Similar Threads
Reputation Points: 17
Solved Threads: 6
Posting Pro in Training
ayesha789 is offline Offline
485 posts
since Jun 2009
Nov 10th, 2009
0
Re: Count Files in Server
Click to Expand / Collapse  Quote originally posted by ayesha789 ...
Dear All,
I am developing a Lease Management System and I have Stored LEase agreements in Folder Named LAPO
I used ID for search.
and in LAPO Folder I have created folders name like 9624
inside 9624, I have stored LA.pdf
There are 2300 folders in LAPO
and 95% of the Folders have LA inside.
1. I want to count these LA.pdf through PHP command or function.
Thanks.
2. Also I want the folder name in which LA.pdf exists.
something like this should work for you -
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $count = 0;
  3. if($handle = opendir('/path/to/dir/LAPO'))
  4. {
  5. echo "Directory handle: $handle\n";
  6. echo "Files:\n";
  7.  
  8. /* This is the correct way to loop over the directory. */
  9. while (false !== ($file = readdir($handle)))
  10. {
  11. is_dir($file)
  12. {
  13. if($handle_inner = opendir($file))
  14. {
  15.  
  16. while(false !== ($file_inner = readdir($handle_inner)))
  17. {
  18. echo "$file\n";
  19. if($file_inner=='LA.pdf')
  20. { $count++; }
  21.  
  22. }
  23. }
  24.  
  25. }//is_dir
  26. }
  27.  
  28. closedir($handle);
  29. }
  30. echo "Number of LA.pdf found inside".$count;
  31. ?>
ask the clarification if any more modification needed
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: getting variable without extension
Next Thread in PHP Forum Timeline: Making tutorials - your wishlist





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC