It is a very simple solution. All you need to do is read an original directory. Then read your new directory. Then If new directory does not contain a file/folder in original directory, then copy it.

Here is what i came up with a sec ago:
use strict; use warnings; use File::Copy::Recursive qw(rcopy); use File::Slurp; use Cwd; my $cwd = cwd(); my $dir = $ARGV[0]; my $orig_dir = "$cwd/$dir"; my $new_dir = "$cwd/your/path/"; my @first_scan = read_dir($orig_dir); #this will build an initial l +ist #and put it into @first_scan; re_scan(); sub re_scan { #to rescan over and over whil +e comparing my @new_scan = read_dir($new_dir); foreach my $element (@first_scan) { if ( $element ~~ @new_scan ) { print "$element Already Exists!\n"; } else { print "Copying $element to $new_dir\n"; rcopy( $orig_dir . $element, $new_dir . $element ); } } undef(@first_scan); for (@new_scan) { push( @first_scan, $_ ); } undef(@new_scan); sleep(3); ; re_scan(); }
This should work for your scenario as you just need to scan the directory, and if the new directory does not contain somethign that the old dir has in it, it copies it.

In reply to Re^5: how to move the folder from one directory to another directory? by james28909
in thread how to move the folder from one directory to another directory? by vasuperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.