azatoth has asked for the wisdom of the Perl Monks concerning the following question:
It is a little script that searches through a directory, checks the last modification of a file, and prompts the user for deletion if it meets certain criteria. As I said, I'm just tinkering. Now, the code at the moment checks for last usage of 30 days or under, here :#!perl -w use strict; print "Enter Directory Path : \n"; chomp(my $dirPath = <STDIN>); opendir (DIR, "$dirPath") || die "Fscked Filesystem: $!\n"; my @fileList = grep(!/^\.\.?$/, readdir (DIR)); closedir (DIR); foreach my $file (@fileList) { check_files($file,$dirPath); } ## SUBS ## sub check_files { my $file = shift; my $dirPath = shift; if (-A $file > 30) { print "$file has not been used for over 30 days. Delete? [y/n +]\n"; chomp(my $ans = <STDIN>); if ($ans =~ /^y/) { unlink ("$dirPath\\$file") || die "Could Not Remove $file +: $!\n"; print "Deleting $dirPath\\$file...\n"; } else { print "Skipping File...\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Attributes in Win32
by Eureka_sg (Monk) on May 01, 2001 at 18:55 UTC | |
by azatoth (Curate) on May 01, 2001 at 19:00 UTC | |
|
Re: File Attributes in Win32
by c-era (Curate) on May 01, 2001 at 18:45 UTC | |
by tye (Sage) on May 01, 2001 at 19:39 UTC | |
|
on fsck
by petdance (Parson) on May 01, 2001 at 19:16 UTC | |
by azatoth (Curate) on May 01, 2001 at 20:27 UTC | |
|
Re: File Attributes in Win32
by jeroenes (Priest) on May 01, 2001 at 18:51 UTC |