Script to copy the files under directory and subdirectories

Here is a script to copy the files from source path directory's and sub directory's  to specified destination directory.

#!/usr/bin/perl -w
my $srcpath='';
my $destpath='';


system("chmod 755 $destpath");
system("chmod 755 $srcpath");

copydir($srcpath);





sub copydir
{
  my $Path = shift(@_);

print "\n My Path : $Path";
  my @arry1=`ls  $Path`;
  foreach $a ( @arry1 )
{
    chomp($a);
   print "\n My File : $a";
     if(-d "$Path/$a")
     {
       $Path1="$Path/$a";
      print "\nFrom IF : $Path1";
       copydir( $Path1 );
     }

     else
     {
      print "\n IT IS A FILE";
      system("cp -p $Path/$a $destpath");
     }
}
}

Number of Hits : Hit Counter by Digits

ADD this Info

Bookmark and Share