"I currently have this bit of code which works fantastic other than I need it to ignore files that have already been copied from directory"
here is what i came up with:
use strict;
use warnings;
use diagnostics;
use File::Copy::Recursive qw(dircopy rcopy);
use File::Path qw(make_path);
my $dirname = "$ENV{USERPROFILE}\\Dropped Box\\";
my $dirname2 = "C:\\Dropped Stuff\\";
my $sleep = 5; # how long to sleep for
while (1) {
opendir( DIR, $dirname ) || die "Error in opening dir $dirname\n";
foreach my $filename ( readdir(DIR) ) {
if ( not -e $dirname2 . $filename ) {
print "copying $dirname$filename to $dirname2$filename\n";
dircopy( $dirname . $filename, $dirname2 . $filename );
rcopy( $dirname . $filename, $dirname2 . $filename );
}
else {
print "files already exists so im skipping\n";
}
}
closedir(DIR);
sleep $sleep;
1;
}
this will check for if files exists and if it doesnt exists in destination, then copy. then it will also update files int he root copy to directory if they have changes, but not directories and sub directorie)
if you dont want to copy a file that has been copied, it would barely be trivial to setup a small condition to check a listfile that gets populated with filenames that have been copied. and add a check to see if the filename exists in the listfile, and if it does skip it :)
oh btw, this will copy any file that gets dropped in the directory. and does NOT do a backup, but that could be easily integrated ;)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.