#A script that check If the available space is less # than 3.5 TB on the V Volume, #and deletes any #SyscoDB database backup files older than 2 weeks. #!/usr/bin/perl use warnings; use strict; use Win32::DriveInfo; my $file; my $dir_to_process = "V:/Backups/SyscoDB"; my $V_TotalNumberOfFreeBytes = Win32::DriveInfo::DriveSpace('v:'); my $V_RoundedTotalNumberOfFreeGigabytes = sprintf("%.2f", ($V_TotalNumberOfFreeBytes/1073741824)); print "The Free Size is : $V_RoundedTotalNumberOfFreeGigabytes GB\n"; if ( $V_RoundedTotalNumberOfFreeGigabytes < 3.5 && $V_RoundedTotalNumberOfFreeGigabytes == 3.5) { opendir DH, $dir_to_process or die "Cannot open $dir_to_process: $!"; foreach $file (readdir DH){ unlink $file or warn "failed on $file: $!\n" if -M $file > 14; } closedir DH; }