in reply to Removing files with extentions of log and date-time.
Basicly, this script will now delete any log file, date-time file, or text file found in a predetermined directory. Thanks once again for your help.#!/usr/bin/perl -w $dir = "(directory path)"; print "Starting Delete Process\n\n"; opendir(DIR, "$dir") || die "No $dir: $!"; @files = grep(!/^\./, readdir(DIR)); @files = sort @files; closedir(DIR); foreach (@files) { print $_, "\n"; if (/\.log$/i || /\.\d+\w+\-\d+\wm$/i || /\.txt$/i) { unlink ("$dir/$_") if (-f "$dir/$_") || print "Unable to delete $_: $!"; } }
|
|---|