Thread: Counting Files

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 1999
    Posts
    13
    Rep Power
    0
    I am trying to count the number of files that have a particular string in their file names in a specified directory. Something like:

    $number = count("*$string*.*");

    Any ideas? Thanks
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Posts
    15
    Rep Power
    0
    this is one way ..
    I think ..

    $path="/path/from/root/specifieddir";
    $string = "sfd";

    $d = dir("$path");
    $i=0;
    while($entry=$d->read()) {
    if($f=str_replace($string,"",$entry){
    $i++;
    }
    }
    print "$i dirs or files in $path contained $string";


    [This message has been edited by kvack (edited January 11, 2000).]

Similar Threads

  1. Can't move or delete it!
    By Hykinsel007 in forum Windows Help
    Replies: 3
    Last Post: June 15th, 2004, 04:41 PM
  2. Reading files that has certain parrent at once
    By cgi_pro in forum Perl Programming
    Replies: 2
    Last Post: January 29th, 2004, 11:13 PM
  3. how to rename files
    By dxgn in forum Perl Programming
    Replies: 1
    Last Post: January 1st, 2004, 02:10 PM
  4. Please help with counting the sizes of files
    By danield in forum Perl Programming
    Replies: 8
    Last Post: December 24th, 2003, 11:20 AM
  5. How can I pack servlet files into a jar file?
    By suryahema in forum Java Help
    Replies: 1
    Last Post: December 18th, 2003, 09:32 AM

IMN logo majestic logo threadwatch logo seochat tools logo