I origianlly thought JavaScript was the way to go to do this (see my original thread at [webmasterworld.com...] but the more I think about it, I think a perl script and cron job would be even better.
Basically, I have to update several .html pages that have the special information on them (index.html and some service pages) and also upload new special graphics.
I think it would be ideal if I could create a folder in the www folder, probably named the date I want to move the files out of that folder into the main www folder (i.e. name the folder 051906/) and then create a cron job that checks the server every night at 12:00 to see if there is a folder that matches that days date, and if so, it moves the contents of the folder to the main www folder.
I only have a working knowledge of perl and cron, I can not create my own, but I can usually fiddle with other peoples scripts and get them to work. Is what I described above possible (and practicle)? Any help is appreciated.
As far as the perl side goes, look into the rename() function or using the File::Copy module which has an actual move() function I believe, although rename() really does the same thing. The operating system can probably handle this too, but that depends on the OS, perl will be a better cross platform solution if that is a consideration.
20060101 (Jan 1, 2006)
20060515 (May 15, 2006)
20060330 (Mar 30, 2006)
etc..
The reason being that they will sort (if archiving and ever finding the data again is is a concern).
Here's some chunks of code that take care of a few Perl date handling issues, (adding 1900 to year, left padding single digit days, figuring days in month, leap year, etc..) They are coded in a verbose manner so you can actually read them.
#
#
($dd,$mm,$yyyy) = (localtime)[3,4,5];
$yyyy = ($yyyy + 1900);
if($dd < 10){ $dd = "0" . $dd; }
if($mm < 10){ $mm = "0" . $mm; }
#
# here's today's date as YYYYMMDD
#
$YYYYMMDD = "$yyyy$mm$dd";
#
#
And here's a sub that will find the number of days in a month...
#
# uncomment next line to debug dates and code
# $debug = "YES";
#
#================
sub DaysInMonth {
#================
#
my $y = $_[0];
my $m = $_[1];
#
if ($debug eq "YES") { print "<BR><B>sub DaysInMonth</B><BR>\n"; }
if ($debug eq "YES") { print "y = $y<BR>\n"; }
if ($debug eq "YES") { print "m = $m<BR>\n"; }
#
if (substr("$m",0,1) eq '0') { $m = substr("$m",1,1); }
#
my $days = '31'; # (default / max value)
#
if ($m eq '1') {
if (isLeapYear($y) eq '1' ) {
if ($debug eq "YES") { print "y = $y<BR>\n"; }
if ($debug eq "YES") { print "isLeapYear(y) = " . isLeapYear($y) . "<BR>\n"; }
$days = '29';
} else {
$days ='28';
}
}
if (($m eq '3') ¦¦ ($m eq '5') ¦¦ ($m eq '8') ¦¦ ($m eq '10')) { $days = '30'; }
#
if ($debug eq "YES") { print "days = $days<BR>\n"; }
#
return $days;
#
}
#
#
You'll also need to know if it's a leap year for February...
#===============
sub isLeapYear {
#===============
#
my $year = $_[0];
#
if ($debug eq "YES") { print "<BR><B>sub isLeapYear</B><BR>\n"; }
if ($debug eq "YES") { print "year = $year<BR>\n"; }
#
if ((($year % 4 == 0) && ($year % 100!= 0)) ¦¦ ($year % 400) == 0) {
return '1';
}
return '0';
}
#
#
Now just duct take them together with your file generating / copying code and you've got a script...<grin>..
Or you could just use one of the CPAN date modules --- (I prefer to roll my own so I don't have to depend on modules being installed).