I do this sort of thing but more in a "cleanup" capacity rather than "backup." The following code simply looks for any files in the current directory with an extension of .xcp and deletes any where the modification date is greater than 10 days old.
#!C:/perl/bin/perl.exe;
use strict;
use warnings;
use Cwd;
# delete .xcp files older than 10 days
#Identify my current directory and record it to $cdir
my $cdir = getdcwd();
#create an array of all files with an exntesion of .xcp
my @files = glob("*.xcp");
foreach my $file (@files) {
# for each element of the array delete if mod date is greater than 10
+days
unlink "$cdir\\$file" if -M $file > 10;
}
A quick google search for "perl file attributes" presented This link to a list of file characteristics (along with many others) you can use as evaluation criteria.I hope this helps.
|