02-12-2019, 10:25 PM
To find the total number of files (and subdirectories) in any directory, just include this snippet in any cgi file in that directory.
$dirt = './';
@files = <$dirt/*>;
$count = $#files + 1;
$#files is the count of the last file. Since operating systems count from zero the last file number requires a plus 1 to achieve the actual total.
Here is a simple page to demonstrate:
http://jawjahboy.com/scripts/perl/filecount.cgi
Here is code that creates the page:
http://jawjahboy.com/scripts/perl/filecount.txt
Here is a very involved application using this snippet to show the count of my smiley and avatar images:
http://jawjahboy.com/Graphics/smileys-av...age-count/
$dirt = './';
@files = <$dirt/*>;
$count = $#files + 1;
$#files is the count of the last file. Since operating systems count from zero the last file number requires a plus 1 to achieve the actual total.
Here is a simple page to demonstrate:
http://jawjahboy.com/scripts/perl/filecount.cgi
Here is code that creates the page:
http://jawjahboy.com/scripts/perl/filecount.txt
Here is a very involved application using this snippet to show the count of my smiley and avatar images:
http://jawjahboy.com/Graphics/smileys-av...age-count/