I see you are under winz OS. I found an ancient (13 years old ?) program by Jenda that do something very similar.
I would post the link if i have found it at monastery, but seem i connot find it. So i post directly the code.
I hope Jenda will not be hurted by this.
### original code by Jenda as found at http://www.perlmonks.org/?node_
+id=105128
#perl -w
# watch_dirs.pl
use strict;
#use G;
use File::Copy;
use Win32::IPC qw(wait_any);
use Win32::ChangeNotify;
use Win32::AbsPath qw(Relative2Absolute);
use Win32::FileOp qw(:DIALOGS);
use vars qw($VERSION $path @paths $i @notify @data $file $pathnum);
$VERSION = "1.0";
if (@ARGV) {
@paths = @ARGV;
Relative2Absolute @paths;
foreach (@paths) {
die "Ussage: watch_dirs.pl [directory ...]\n\t\tversion $VERSI
+ON by Jenda.Krynicky.cz (c) 2001\n"
unless -d $_;
}
} else {
while (1) {
$path = BrowseForFolder "Watch directory for changes\nClick [C
+ancel] to finish directory selection" , CSIDL_DRIVES, BIF_RETURNONLYF
+SDIRS
or last;
push @paths, $path;
}
die "OK. No directory selected. I'm quiting.\n"
unless @paths;
}
print "Watching directories:\n";
for ($i=0;$i<=$#paths;$i++) {
$path = $paths[$i];
print "\t$path\n";
mkdir $path.'\\_b_a_c_k_u_p', 0777;
opendir DIR, $path;
while ($file = readdir DIR) {
next if -d $path.'\\'.$file;
$data[$i]->{$file} = (stat($path.'\\'.$file))[9];
}
closedir DIR;
push @notify, Win32::ChangeNotify->new($path,0,"LAST_WRITE SIZE FI
+LE_NAME");
};
print "\n";
while (1) {
$pathnum = wait_any(@notify) or die "Can't monitor the directory:
+$!\n";
$pathnum--; # arrays always start from zero not one
my $pathdata = $data[$pathnum];
my $path = $paths[$pathnum];
opendir DIR, $path;
while ($file = readdir DIR) {
next if -d "$path\\$file";
my $time = (stat("$path\\$file"))[9];
if ($pathdata->{$file} != $time) {
print "$path\\$file has changed!\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= localtime(time);$mon++;$year += 1900;
my $timestr = sprintf '%04d%02d%02d-%02d%02d%02d',$year,$m
+on,$mday,$hour,$min,$sec;
copy "$path\\$file" => "$path\\_b_a_c_k_u_p\\$file.$timest
+r";
$pathdata->{$file} = $time;
}
}
closedir DIR;
$notify[$pathnum]->reset;
}
=pod PerlApp
perlapp watch_dirs.pl -f -c -x "-info=fileversion=1.0;productversion=1
+.0;internalname=watch_dirs.pl 1.0;originalfilename=watch_dirs.exe;com
+panyname=Jenda Krynicky;productname=watch_dirs;legaltrademarks=Jenda.
+Krynicky.cz;filedescription=Watch dirs for changes and make backup;le
+galcopyright=Jenda.Krynicky.cz"
=cut
HtH L*
UPDATE:i was seraching in the wrong place: the program is at his homesite!
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|