blowupp has asked for the wisdom of the Perl Monks concerning the following question:
Blessings Monks,
Have read archives but failed to make a housekeeping script that culls aged folders and anything they contain.
My current effort leaves the directories behind as they become date modifed when contents are deleted.
May I please ask any kind soul for help with the solution.
yours
Mark
#!/usr/bin/perl use strict; use warnings; use File::Find; my $limit = 180; find (\&CheckFile, "/my.co.uk/video/testdelete/"); sub CheckFile { $File::Find::dir; my $age = -M; if ( -f $File::Find::dir && $age > $limit ) { system ( 'rmdir','-r', "$File::Find::dir") or die "delet +e failed: $!"; } else { print $File::Find::name; print " is ",int($age)," days old\n"; }}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ahem... the old delete files n' folders again.
by wind (Priest) on May 12, 2011 at 15:47 UTC |