Added compare logic to archive statements
This commit is contained in:
parent
517c1f54b6
commit
3475eadfe5
1 changed files with 14 additions and 2 deletions
|
|
@ -58,10 +58,12 @@ dircopy($financial_folder, $lastyear_folder) or die $!;
|
||||||
compare_dirs( $financial_folder, $lastyear_folder );
|
compare_dirs( $financial_folder, $lastyear_folder );
|
||||||
|
|
||||||
# Delete all files from current year from archive folders
|
# Delete all files from current year from archive folders
|
||||||
|
delete_dirs($financial_folder, $lastyear_folder, $year, $lastyear);
|
||||||
|
|
||||||
# compare new directories to old directories to make sure they are the same
|
# compare new directories to old directories to make sure they are the same
|
||||||
sub compare_dirs {
|
sub compare_dirs {
|
||||||
my ( $dir1, $dir2 ) = @_;
|
my ( $dir1, $dir2 ) = @_;
|
||||||
|
print("Making sure the copy was complete and all files match\n");
|
||||||
File::DirCompare->compare($dir1, $dir2, sub {
|
File::DirCompare->compare($dir1, $dir2, sub {
|
||||||
my ($a, $b) = @_;
|
my ($a, $b) = @_;
|
||||||
if (! $b) {
|
if (! $b) {
|
||||||
|
|
@ -74,9 +76,19 @@ sub compare_dirs {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete old directory
|
# Delete old files
|
||||||
sub delete_dirs {
|
sub delete_dirs {
|
||||||
# For all files in archive dir that are newer than last year delete them
|
my ( $new_dir, $old_dir, $curr_year, $last_year ) = @_;
|
||||||
|
print("Deleting files from current year in archives\ and");
|
||||||
|
print("files from last year from current folder\n");
|
||||||
|
|
||||||
|
# For all files in archive dir that are newer than last year delete them
|
||||||
|
my $find_rule = File::Find::Rule->new;
|
||||||
|
# $find_rule->nonempty->maxdepth(1)->mindepth(1)->relative;
|
||||||
|
$find_rule->name('*.' . $lastyear . '*');
|
||||||
|
my @curr_subdirs = $find_rule->directory->in( $new_dir );
|
||||||
|
foreach $subdir(@curr_subdirs) {
|
||||||
|
print("THING");
|
||||||
|
}
|
||||||
# For all file in current folder that are older than this year delete them
|
# For all file in current folder that are older than this year delete them
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue