Hello, Using PHP 4, is there a fucntion that counts the files in a
given directory? You can assume there are no sub-directories within
this directory and hence, no files within the sub-directories.
Thanks for any functions or one-liners. - Dave 4 30289 la***********@z ipmail.com schreef:
Hello, Using PHP 4, is there a fucntion that counts the files in a
given directory? You can assume there are no sub-directories within
this directory and hence, no files within the sub-directories.
Thanks for any functions or one-liners. - Dave
Hi Dave,
You could use readdir to accomplish this.
Example:
<?php
function countFiles($str DirName)
{
if ($hndDir = opendir($strDir Name))
{
$intCount = 0;
while (false !== ($strFilename = readdir($hndDir )))
{
if ($strFilename != "." && $strFilename != "..")
{
$intCount++;
}
}
closedir($hndDi r);
}
else
{
$intCount = -1;
}
return $intCount;
}
echo countFiles("C:\ \Temp");
?>
HTH.
Peter.
-- http://www.phpforums.nl
<comp.lang.ph p>
<la***********@ zipmail.com>
<23 Jul 2006 06:48:02 -0700>
<11************ *********@75g20 00cwc.googlegro ups.com>
Hello, Using PHP 4, is there a fucntion that counts the files in a
given directory? You can assume there are no sub-directories within
this directory and hence, no files within the sub-directories.
Thanks for any functions or one-liners.
<?php
$dirname="demo" ;
$dh=opendir($di rname);
while ($dave=readdir( $dh))
{
print "$dave <br>";
}
closedir ($dh);
?>
--
Encrypted email address www.emailuser.co.uk/?name=KRUSTOV
Make a shorter url www.vhit.co.uk
<comp.lang.ph p>
<Krustov>
<Sun, 23 Jul 2006 15:54:51 +0100>
<MP************ ***********@new s.newsreader.co m>
<?php
$dirname="demo" ;
$dh=opendir($di rname);
while ($dave=readdir( $dh))
{
print "$dave <br>";
}
closedir ($dh);
?>
I missed the bit where you said count .
<?php
$cnt=0;
$dirname="demo" ;
$dh = opendir($dirnam e);
while ($dave=readdir( $dh))
{
print "$dave <br>";
$cnt=$cnt+1;
}
closedir ($dh);
print $cnt-2;
?>
--
Encrypted email address www.emailuser.co.uk/?name=KRUSTOV
Make a shorter url www.vhit.co.uk la***********@z ipmail.com wrote:
Hello, Using PHP 4, is there a fucntion that counts the files in a
given directory? You can assume there are no sub-directories within
this directory and hence, no files within the sub-directories.
Thanks for any functions or one-liners. - Dave
count(glob("$di r/*.*")); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: rbt |
last post by:
I assume that there's a better way than this to count the files in a
directory recursively. Is there???
def count_em(valid_path):
x = 0
for root, dirs, files in os.walk(valid_path):
for f in files:
x = x+1
print "There are", x, "files in this directory."
return x
|
by: Darren |
last post by:
Hi Group,
Any ideas how to check for files in a directory, to see if any are of the
same prefix, and make a count of them.
I have a round 100 files, the filename is made up of an engineer number
followed by a contract number.
I want to see how many files each engineer has:
|
by: Terry E Dow |
last post by:
Howdy,
I am having trouble with the objectCategory=group member.Count attribute.
I get one of three counts, a number between 1-999, no member (does not
contain member property), or 0. Using LDIFDE as a comparison I get the same
results. No members means just that, an empty group. Zero means that the
DirectorySearcher.SizeLimit has been exceeded....
|
by: Dale |
last post by:
Is there a way to determine the number of hidden files/directories within a
directory? This is what I’m doing now:
System.IO.DirectoryInfo rootPath;
System.IO.FileSystemInfo dirs, files;
int numOfDirs = 0, numOfFiles = 0;
di = new System.IO.DirectoryInfo(“blah”);
dirs = rootPath.GetDirectories();
files = rootPath.GetFiles();
|
by: Bruce |
last post by:
Is there a mechanism within VS 2005 to determine the number of source code
lines in a C# project (either per file or across the entire project)?
Thanks, Bruce
| |
by: glub glub |
last post by:
i'm trying to make a program that works as Replace works in MS Word but this
is for use with files, not a text document.
FolderBrowserDialog1.ShowDialog()
txtPath.Text = FolderBrowserDialog1.SelectedPath
above are the 2 lines of code i have so far, i would like to display/add the
files to a list view and i feel that i would have to count the amount of
files in the specified directory to do so, so how would i count the amount
of files...
|
by: MichiMichi |
last post by:
My asp.net application has a directory which is filled up with over 17
files (email) a second. After a while this sums up into a huge amount
of files.
I usually count files with the GETFILES method. This works perfectly
of there are only a few hundert files in the folder
*********
.....
Dim files() As String
|
by: G E W hittle |
last post by:
I have a directory of tiff files. I need to loop thru the files and
count the number of pages in each file. Can someone point me to where
this info is stored?
GW
|
by: flavourofbru |
last post by:
Hi,
I have a small question.
How do I compute the number of files(which are specific such as .doc) in a directory in C++.
For example, if I have 10 files of type .doc format in a directory, how do I compute this value using C++.
Any help is appreciated.
Thanks!!
|
by: briggs |
last post by:
Hi All,
I need to take the count of txt and bak files present in all the directory.for eg if we assume there are two directoies say(test1, test2), I need to collect the count(of txt and bak files) and print it out..
I tried the below code, but could not achieve what I need.Can someone help me on the same.
Prg:
($dir, $extension) = @ARGV;
$dir = "." unless $dir;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |