Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > List of directories with a directory

Reply
Thread Tools

List of directories with a directory

 
 
Al Moodie
Guest
Posts: n/a
 
      01-30-2008
I have a directory with 200 sub directories in it. How do I create a
list of the sub directory names?

I know how create a list of all the files in a directory:

opendir(DIR, $dirname) or die "can't open $dirname: $!";
while (defined($file = readdir(DIR))) {
next if($file =~ m/^\./);
next if($file eq "");
push (@filenames, $file);
}
closedir(DIR);

but how do I do it for the directories within a directory

Al Moodie.
 
Reply With Quote
 
 
 
 
Al Moodie
Guest
Posts: n/a
 
      01-30-2008
On Tue, 29 Jan 2008 19:45:50 -0500, Al Moodie <(E-Mail Removed)>
wrote:

>I have a directory with 200 sub directories in it. How do I create a
>list of the sub directory names?


I have the answer from another source.

Al Moodie.
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      01-30-2008
Al Moodie <(E-Mail Removed)> wrote:
>I have a directory with 200 sub directories in it. How do I create a
>list of the sub directory names?
>
>I know how create a list of all the files in a directory:
>but how do I do it for the directories within a directory


I would simply use File::Find and prune the search tree ata depth of 2.

jue
 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      02-05-2008
Al Moodie wrote:
> On Tue, 29 Jan 2008 19:45:50 -0500, Al Moodie <(E-Mail Removed)>
> wrote:
>
>> I have a directory with 200 sub directories in it. How do I create a
>> list of the sub directory names?

>
> I have the answer from another source.


Was it anything like this:

perl -MFile::Find -e 'find(sub {push @files,$File::Find::name if -f $_},@ARGV); \
print join "\n","Found:",@files,"";' /etc/rc.d
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
virtual directories/physical directories in IIS Paul F ASP .Net 4 06-25-2008 04:04 PM
Multiple bin-directories with virtual directories? =?Utf-8?B?TGFzc2UgTmlsc3Nvbg==?= ASP .Net 0 11-09-2004 05:49 PM
Getting all directories/files from current directory and using -d flag for the directories Adam Petrie Perl Misc 8 10-11-2004 01:28 PM
How to map Project directories to Production sub-directories Joel Finkel ASP .Net 0 09-12-2003 06:47 PM
Using virtual directories for common directories (scripts, images, styles, etc.) Jeffry van de Vuurst ASP .Net 2 07-30-2003 07:00 PM



Advertisments