in reply to Re^4: how to move the folder from one directory to another directory?
in thread how to move the folder from one directory to another directory?
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.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(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: how to move the folder from one directory to another directory?
by marto (Cardinal) on Dec 28, 2014 at 09:22 UTC | |
by james28909 (Deacon) on Dec 28, 2014 at 09:42 UTC | |
|
Re^6: how to move the folder from one directory to another directory?
by Anonymous Monk on Dec 28, 2014 at 16:50 UTC | |
by james28909 (Deacon) on Dec 28, 2014 at 23:14 UTC | |
by Anonymous Monk on Dec 28, 2014 at 23:20 UTC | |
by james28909 (Deacon) on Dec 28, 2014 at 23:35 UTC |