🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #19599

Re: Quick way to list how many files in a each subdirectory?

#19599
From: Charles Ball
Date: Thu, 24 Jul 1997 00:00
42 lines
1680 bytes
You really don't want to use find to traverse a news spool; it will stat each
file looking for directories.  

Here's a utility customized for counting articles in a news spool.
It uses $inn::active to identify directories and perl's readdir to return
the number of files in each news spool directory.  Like find(1)'s  "-ls"
function, this also skips the filename sort.


/news/local/countnewsgroups:
#!/usr/local/bin/perl 
require "/news/etc/innshellvars.pl"; 
use DirHandle;
use FileHandle;
 
  
my (%newsgroup, @active, @dir, $dir, $DH, );
my $ACTIVE = new FileHandle "<$inn::active";
   
while (<$ACTIVE>) {
	@active = split;

	($dir = $active[0]) =~ s,\.,/,g;

	$DH = new DirHandle "$inn::spool/$dir";
	next if !defined($DH);
	@dir = (readdir($DH));

		#set $newsgroup{<groupname>} ::= #articles
	$newsgroup{$active[0]} = @dir;

		#debugging
	#print sprintf "$active[0]: %d\n", scalar(@dir);
}

        #print newsgroup article counts in decreasing order
foreach $group (sort {$newsgroup{$b} <=> $newsgroup{$a}} keys %newsgroup) {
	print "$group: $newsgroup{$group}\n";
	}

Technical Details
Message-ID: <5r88jh$nq7$1@news1.bu.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <823ep57gog.fsf@manic.eecs.umich.edu>

Show Full Headers
Complete Article Headers
Message-ID: <5r88jh$nq7$1@news1.bu.edu>
Subject: Re: Quick way to list how many files in a each subdirectory?
Date: Thu, 24 Jul 1997 00:00:00 +0000
From: cball@bu.edu (Charles Ball)
References: <823ep57gog.fsf@manic.eecs.umich.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 258547777
Organization: Boston University
Newsgroups: news.software.nntp