Article View: es.comp.os.linux.programacion
Article #1040Re: GOLF: averiguar directorios con un único archivo dentro
From: gamo
Date: Mon, 10 Apr 2006 21:47
Date: Mon, 10 Apr 2006 21:47
48 lines
2269 bytes
2269 bytes
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--8323328-800210553-1144705656=:21536
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
On Sun, 9 Apr 2006, David Serrano (Hue-Bond) wrote:
> Por si alguien se aburre (tanto como yo) (que no creo)...
>=20
> En un directorio cualquiera (por ejemplo, uno llamado "mp3" ;^)) tenemos =
un
> mont=F3n de directorios en los que dentro puede haber:
>=20
> a) varios archivos y/o directorios
> b) un =FAnico directorio
> c) un =FAnico archivo regular
>=20
#!/usr/local/bin/perl -w
ver("/home/");
sub ver{
my $DIR =3D shift ;
my $count=3D0;=09=09
print "DIR-> $DIR\n";
opendir DIR, $DIR or warn "Cannot open $DIR";
my @files =3D readdir DIR;
closedir DIR;
for my $i (@files){
next if ($i=3D~/^\.\z/ || $i=3D~/^\.\.\z/);
# print "$i\n";
=09$count++;
$newdir =3D $DIR.$i."/";
if ( (chdir $newdir) ){
ver($newdir);
}
}
if ($count=3D=3D1) { print "$DIR has only 1 item\n"; }=09
}
__END__
UNTESTED
--8323328-800210553-1144705656=:21536--
Technical Details
Message-ID:
<Pine.LNX.4.64.0604102337350.21536@jvz.es>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!opentransit.net!newsfeed.telecable.es!cm-83-97-181-149.telecable.es!amoReferences:
<slrne3io3q.2r9.responder_solo_en_el_grupo@genus.hue-bond.info>Show Full Headers
Complete Article Headers
X-Google-Thread: f86c8,9ee7624a08527b65 X-Google-Attributes: gidf86c8,public X-Google-Language: SPANISH,ASCII Newsgroups: es.comp.os.linux.programacion Date: Mon, 10 Apr 2006 23:47:36 +0200 From: gamo <gamo@telecable.es> X-X-Sender: amo@jvz.es Reply-To: gamo@telecable.es Subject: Re: GOLF: averiguar directorios con un único archivo dentro In-Reply-To: <slrne3io3q.2r9.responder_solo_en_el_grupo@genus.hue-bond.info> Message-ID: <Pine.LNX.4.64.0604102337350.21536@jvz.es> References: <slrne3io3q.2r9.responder_solo_en_el_grupo@genus.hue-bond.info> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-800210553-1144705656=:21536" NNTP-Posting-Host: 83.97.181.149 X-Trace: filemon1.isp.telecable.es 1144705556 83.97.181.149 (10 Apr 2006 23:45:56 +0200) Organization: TeleCable, S.A.U. Lines: 48 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!opentransit.net!newsfeed.telecable.es!cm-83-97-181-149.telecable.es!amo