#! /usr/bin/perl -w # Testing signiant code # Author: #use strict; use diagnostics; use File::Find; # Variable "Error" contains any error of previous task runs. # Variable "ThisMoveTarget" contains destination archive location path. If this stores a path (i.e if directories are archived) then # the main body of code (i.e walk down the source location for deleting empty directories) should execute my $Error = "0" ; # my $ThisMoveTarget = q|holds location where archive files should go |; my $ThisMoveTarget = '/home/ssaha/tmp/archive'; # our $DelEmptyFoldrArchive = q|holds yes or no |; our $DelEmptyFoldrArchive = "yes "; # our $ThisSourceDirectory = q|holds the source file location |; our $ThisSourceDirectory = "/home/ssaha/tmp/source"; #our $ThisSourceDirectory = "\\hostname\share-test\"; if (($DelEmptyFoldrArchive eq "yes ")&&($ThisMoveTarget)) { if (($ThisSourceDirectory)&&("$Error" == 0)) { find(\&filter, $ThisSourceDirectory); sub filter() { return unless -f; our $file = $_; print STDERR "$file \n " ; } if ($file) { print STDERR "The $ThisSourceDirectory has files present \n" ; } elsif (!$file) { finddepth (sub { rmdir $_; }, $ThisSourceDirectory); } } elsif (($ThisSourceDirectory)&&("$Error" != 0)) { print STDERR "JOB Completed with Errors, Source Agent used was SRCHOST\n" ; } } else { print STDERR "DelEmptyFoldrArchive is $DelEmptyFoldrArchive, skipping directory deletion. \n" ; } # __END__