#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    79
    Rep Power
    2

    I thought I could use File::Path


    Hi,
    I need to copy and recreate a directory tree that has about 2000 subfolders.I thought I could use File::Path but apparently the module creates only the parent folder and then it stops. Are there any other modules I could use to do the job?
    Thanks, testerV

    Tried all of this but could not make it work.

    Code:
    #!/usr/bin/perl
      use strict;
      use warnings;
      use File::Path qw(make_path ) ;
     
          my $from = "O:/JVC" ;
          my $to   = "C:/JVC" ;
                       
                        make_path('$from', '$to',
                          {
                             verbose => 1,
                             mode => 0711,
                          });
    Code:
      make_path('$from', '$to');

    Code:
      make_path('O:/JVC', 'C:/JVC');
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    /dev/null
    Posts
    162
    Rep Power
    18
    Use File::Copy::Recursive module.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    79
    Rep Power
    2
    Thank you very much !!!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    79
    Rep Power
    2
    Hi,
    I still cannot make it work.
    The module works nice if I need to copy a whole directory but I want to copy just directory tree.
    I tried to use
    Code:
    File::Copy::Recursive::pathmk ($from,$to ) or die $!;
    and
    Code:
    File::Copy::Recursive::rcopy ($from,$to ) or die $!;
    Thanks, testerV
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    79
    Rep Power
    2
    Hi,
    Thanks for the help!
    testerV

    Code:
    #!/usr/bin/perl
     use strict;
     use warnings;
     use File::Path qw(make_path ) ;
     use File::Find::Rule;
     
                my $from = 'O:/Some/Dir' ;
                my ($netdir, $newlocdirs) ;
     
      my @subdirs = File::Find::Rule->directory->in($from );  
                    for $netdir (@subdirs) 
                       {
                         print $netdir, "\n" ;
                        ($newlocdirs = $netdir) =~s/O/C/ ;
                         $newlocdirs =~s/\\/\//;
     
                         unless(-d "$newlocdirs")              
                       { 
                         make_path("$newlocdirs", 0, 0755); 
                        } 
                      }
                        exit ;

IMN logo majestic logo threadwatch logo seochat tools logo