ibanix has asked for the wisdom of the Perl Monks concerning the following question:
### Delete pdf files older than X days from given directory tree ### use strict; use warnings; use File::Find; my @directories; $directories[0] = $ARGV[0]; my $days_old = $ARGV[1]; finddepth(\&wanted, @directories); # File::Find coderef # Find all PDFs older than given # of days & delete sub wanted { # Turn forward slashes into backslashes to make real Win32 paths my $file = $File::Find::name; $file =~ s|/|\\|g; if ( ($file =~ m|\.pdf$|) && (int(-M $file) > $days_old) ) { print "Found: $file, deleted\n"; unlink($file) || print "Unable to delete $file!\n"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Some File::Find woes. ($_ not $name)
by tye (Sage) on Jan 12, 2004 at 21:50 UTC | |
by ibanix (Hermit) on Jan 13, 2004 at 20:14 UTC | |
Re: Some File::Find woes.
by bluto (Curate) on Jan 12, 2004 at 23:50 UTC | |
Re: Some File::Find woes.
by Tommy (Chaplain) on Jan 13, 2004 at 00:52 UTC | |
by dominix (Deacon) on Jan 13, 2004 at 11:04 UTC | |
by cLive ;-) (Prior) on Jan 13, 2004 at 05:03 UTC | |
Re: Some File::Find woes.
by paulbort (Hermit) on Jan 13, 2004 at 18:39 UTC | |
by Tommy (Chaplain) on Jan 15, 2004 at 23:07 UTC | |
Re: Some File::Find woes.
by scratch (Sexton) on Jan 13, 2004 at 18:01 UTC |