#!/usr/bin/perl -w # # Usage: oldfiles [#months] # $monthdays = 365 / 12; # Number of days in a month $minage = $monthdays * 6; # Default Minimum Age of a file (6 months +) # # Process months argument, if any # if ($#ARGV >= 0) { $minage = $monthdays * $ARGV[0]; } # # Skate down the ole directory tree # &traverse('.'); sub traverse { local($dir) = shift; local($path); unless (opendir(DIR, $dir)) { warn "Can't open $dir\n"; closedir(DIR); return; } foreach (readdir(DIR)) { next if $_ eq '.' || $_ eq '..'; $path = "$dir/$_"; if ((-d $path) && (! -l $path)) { # non-symlink dir, enter +it &traverse($path); } elsif ((-f _) && (! -l $path)) { # plain file, but not a +symlink $age = -A $path; # get age in days if ($age > $minage) { $size = -s $path; printf "%4d days %9d bytes %s\n",int($age),$size,$path +; } } } closedir(DIR);

In reply to Re: Deleting files by JSchmitz
in thread Deleting files by mallen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.