Count Files in Server

Reply

Join Date: Jun 2009
Posts: 214
Reputation: ayesha789 is an unknown quantity at this point 
Solved Threads: 3
ayesha789's Avatar
ayesha789 ayesha789 is offline Offline
Posting Whiz in Training

Count Files in Server

 
0
  #1
Nov 10th, 2009
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.
Ayesha
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 557
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 64
network18 network18 is offline Offline
Posting Pro
 
0
  #2
Nov 10th, 2009
Originally Posted by ayesha789 View 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.
something like this should work for you -
  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
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC