TechGrabage

September 15, 2005

PERL: Copy Files Changed Yesterday

Filed under: Windows

After mangling several batch files and bastardizing a few other scripts I decided it was time to delve into PERL. I have been wanting to learn PERL for quite some time now and finnnaly wrote my first script today… Here it is in all its glory…

c:\perl\bin\perl.exe

Created on 9/15/2005 - Mike M

use File::Copy;

$dir=”c:\htrdata\keene1″;

$destdir=”\\cifp01\pubworks\wwtp\ZETABACKUP”;

opendir(MY_DIR, $dir) || die(”I can’t OPEN IT!”);

@files= readdir(MY_DIR);

closedir(MY_DIR);

foreach $f (@files)

{

$age=int(-M $dir."\\".$f);

if($age == 1) {

#print "$f $age\n";

copy($dir."\\".$f,$dest_dir."\\\\".$f) or die "Copy Failed!";

}

}

-mwm

Comments »

The URI to TrackBack this entry is: http://techgrabage.blogsome.com/2005/09/15/perl-copy-files-changed-yesterday/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>























Get free blog up and running in minutes with Blogsome | Theme designs available here