Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Hide my ageing work

by blowupp (Novice)
on Oct 26, 2008 at 08:59 UTC ( [id://719629]=note: print w/replies, xml ) Need Help??


in reply to Re: Hide my ageing work
in thread Hide my ageing work

With all the suggested weekend reading something has rubbed off & I have disturbed the Monks again to boast that I've cracked it!
Here is my perl effort; A script to rename aged files, for the Monks archives;


#! /usr/local/bin/perl
use strict;
use warnings;
use File::Find;
#set the age tolerance
my $limit = 16;

#call the find subroutine
find (\&CheckFile, "/path to your directory");
#subroutine
sub CheckFile {
$File::Find::name;
my $age = -M;
#test the age
if (-f && ($age > $limit)) {
print $File::Find::name;
print " is ageing at ",int($age)," days old\n";
rename ( $_, "XYZ.$_;") or die "rename failed: $!";
}
else {
print $File::Find::name;
print " is a youthful ",int($age)," days old\n";
}
}


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://719629]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-19 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found