diff --git a/file_processing/archive_statements.pl b/file_processing/archive_statements.pl index 0e98b98..30c9867 100755 --- a/file_processing/archive_statements.pl +++ b/file_processing/archive_statements.pl @@ -58,10 +58,12 @@ dircopy($financial_folder, $lastyear_folder) or die $!; compare_dirs( $financial_folder, $lastyear_folder ); # 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 sub compare_dirs { my ( $dir1, $dir2 ) = @_; + print("Making sure the copy was complete and all files match\n"); File::DirCompare->compare($dir1, $dir2, sub { my ($a, $b) = @_; if (! $b) { @@ -74,9 +76,19 @@ sub compare_dirs { }); } -# Delete old directory +# Delete old files 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 }