#! /usr/bin/perl -w use strict; use diagnostics; use File::Find; # 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 $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"; my $file ; if ($DelEmptyFoldrArchive eq "yes ") { print STDERR "Debug3: entering check1 \n" ; find({ wanted => \&wanted, no_chdir => 1 }, $ThisSourceDirectory); if ($file) { print STDERR "Debug3: entering check2 file is file \n" ; print STDERR "The $ThisSourceDirectory has files present \n" ; } elsif (!$file) { print STDERR "Debug3 entering check3 file is no file\n" ; finddepth (sub { print "rmdir $_\n"; }, $ThisSourceDirectory); } } else { print STDERR "Debug3: entering check5 \n" ; print STDERR "DelEmptyFoldrArchive is $DelEmptyFoldrArchive, skipping directory deletion. \n" ; } sub wanted { return unless -f; $file = $_; print STDERR "$file \n " ; }