RE: Looking for a faster way of getting a directory listing from a disk



Ed Panni wrote:

: I was wondering if there is a quicker way of getting a directory
: listing from a disk. I am currently doing the following but it
: takes a bit of time if I happen to have to search multiple 250Gb
: drives.

You are searching through a lot of files. Perhaps the best way
to speed things up is to change your algorithm. Instead of
collecting all the files first, why not process each wanted file
as it is found? You might also be able to break the task down
into more manageable chunks of files. Perhaps 10 or 20 GB sections
of the disks at a time. The File::Find module will help make this
easier.


: $i = c d e;

No quoting? That doesn't look good.


: @array = "";

Why set the first element to ""? Why name an array "array"?
We already know it's an array. Why not use something like @files?


: foreach $i (split/ /,$disk) {

$disk has not been defined yet. Perhaps you meant $i?



: print "\nChecking $i: for the tests.....";
: @array1= `dir $i:\\ /B /S`;

Perl has built-in directory functions. You might also find the
File::Find module useful. It will recurse directories and allows
you to filter for certain files. File::Find::Rule is very
convenient, though still slow on an entire drive.


: # Establish a count of how big the array is for stepping
: through the array later to find the .exe file
:
: $lineC = @array1;

$lineC will reset for each drive. That's not what you
probably want. Everything in @array will be one big array when
the loop is finished, not separate arrays for each drive. It
sounds like you need a hash of arrays keyed to drive letters,
not a simple array.


: # append the array if more than one disk is selected
:
: push(@array, @array1);
:
: }

Read the "perlfunc" file, especially directory functions.
Start with "opendir" and follow the links to related functions.
There's an example of reading a directory under the readdir
function. The File::Find module is the most popular way to
safely recurse directories.

Read up on the use of strictures and warnings. You have a
sloppy programming style which will hurt you down the road.
Start every script with these modules. Think of them as
training wheels. They are needed until you find your balance.

use strict;
use warnings;
use diagnostics;



Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.

.



Relevant Pages

  • SUMMARY: 6120 Disk Array-> Remove and Replace Disk, does not enable
    ... the not-latest) firmware for the array which resulted in failure to ... I was able to source a pair of sun-part drives (good used working ... arrays has a disk that went bad - not a problem since we're running ...
    (SunManagers)
  • Re: RAID 0
    ... The OP has four drives. ... Creating a RAID5 array out of 3 of them and using ... It sounds like you have a hardware RAID ... I have discovered in the Disk Management console I ...
    (microsoft.public.windows.server.sbs)
  • Re: Raid 1+0 Configuration (0+1?)
    ... logical drives aon a single drive array. ... files may be on different physical drives. ... > Keep in mind that if you have one large RAID array it will remain one ... Disk ...
    (microsoft.public.sqlserver.server)
  • Re: [opensuse] Re: [OT] vmware and fake scsi devs
    ... Single threaded access to a raid array may not be helped by adding ... effectively each disk can do N IOPS ... So if you have M drives, ... Read original sector, ...
    (SuSE)
  • Re: Is reiserfs slower to mount / on bootup?
    ... When a disk starts failing in a RAID5 array, ... >> it's Reiserfs I'd start seeing appearing and disappearing files, ... >> a final backup before swapping out drives. ...
    (comp.os.linux.setup)