Oops! Forgot the add the script to my previous reply. My apologies!

chuck
#!/usr/bin/perl 
#    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
#       if $running_under_some_shell;
# created using find2perl 
# 10/1/00 chuckc
# 10/5/00 cleaned up and documented (sort of ;)
#
require "find.pl";
usage() if ($#ARGV < 4);
my $startPath   = shift;
my $age                 = shift;
my $macroFile   = shift;
my $prefix              = shift;
my $descr               = shift;
# define option parameter with a value
my $maxFiles    = 0;
$maxFiles               = shift;
my $totalSize   = 0;
my $numFiles    = 0;

open(ARCH,   ">$macroFile") || die "cant open ARCH: $!\n";
&find($startPath);
print ARCH '*'."Total bytes saved: $totalSize\n";
print ARCH '*'."Total number of files archived: $numFiles\n";
exit;

sub wanted {
        #gather data about each file even though we don't really need it all.
    
(($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) 
= lstat($_));
    if ( (-f _) && (int(-A _) > $age) ) {
        # replace the /s that perl likes with \s that DumbOS requires
        $name =~ s%/%\\%g; 
        $totalSize += $size;
        $name =~ s/.*:\\/$prefix/;
        $numFiles += 1;
        print ARCH "arc -del -descr=" . '"' . $descr . '"' . ' "' . $name . '"' . "\n";
        #print to STDIO to prove we are doing something (only old files shown)
        print "$name\n";
    }
    # bail out if we have the number of files we want (good for testing)
    if ($maxFiles > 0 && $numFiles >= $maxFiles) {
                print ARCH '*'."Total bytes saved: $totalSize\n";
                print ARCH '*'."Total number of files archived: $numFiles\n";
                exit;
    }
}

sub usage {
        print "Usage:\n";
        print "\tfileage.pl START_PATH AGE_IN_DAYS TARGET_FILE PREFIX DESCR [MAX 
NUMBER OF FILES]\n";
        print 'Example: fileage.pl L:\PATH 366 OUTFILE.TXT \\NETWARE\VOL1\ "ARCH 
DESC"' . "\n";
        exit 1;
}


---------------------------------------------------------
Chuck Colht
Network Administrator
Chugach Electric Association
[EMAIL PROTECTED]


>>> [EMAIL PROTECTED] 10/05/00 09:13AM >>>
Hello,
        We have a process that archives a large set of files.  We are running 
into a problem now because the number of files is apparently too great for the 
command interpretor (shell) to accept as individual arguments.  We use this 
particular method so that we can archive all these files with the same 
description, and using the same timestamp.  Is anyone aware of a method of 
using an input file to list all the files required to be archived.  If not, 
can we fool the shell by putting double quotes around all the files, 
essentially using this as one argument only?

Any help would be appreciated.

-Matt

Reply via email to