use strict; use warnings; use File::Find::Rule qw( ); use POSIX qw( strftime ); { my $ts = strftime('[%Y/%m/%d %H:%M:%S]', localtime()); my @files = File::Find::Rule->file() ->name('some_file_x') ->mtime('>' . 7*24*60*60) ->in('in_some_dir'); foreach my $file (@files) { if (unlink($file)) { print("$ts Deleted $file\n"); } else { print("$ts Failed to delete $file\n"); } } }
You could limit the number of changes by having the find tool simply print out a list of filenames to delete, then pipe the result to Perl to do the unlink and print.
In reply to Re: Logging deleted files
by ikegami
in thread Logging deleted files
by ppantazis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |