cheers
linda
<?php
$dh = opendir(temp) or die ("Could not open temp directory");
while (false!== ($file = readdir($dh)))
{
if ($file!= "." && $file!= "..")
{
unlink("temp/$file") ;
echo "<font face=Verdana size=1>All Files Deleted...</font>";
}
}
?>
#!/usr/bin/perl
opendir(temp,"/path/to/temp") or die ("Could not open temp directory");
while ($file = readdir(temp))
{
if ($file ne "." && $file ne "..")
{
unlink("/path/to/temp/$file") or warn "Failed to delete file: $file" ;
}
}
print "<font face=Verdana size=1>Done deleting files...</font>";
I am also using windows hosting and the code below deletes the entire contents of the directory, can someone help me convert it so that instead of deleting all the files it only deletes files that are 2 days old?
my $dir = "c:/path/to/dir";
foreach (<$dir/*>){
unlink;
}
i've been told its possible
thanx in advance.
my ($modified, $created) = (stat ($filename)) [9, 10];
$current = time();
my $current = time();
foreach my $filename (<c:/path/to/dir/*>){
unlink $filename if $current - (stat $filename) [10] > 2 * 60 * 60 * 24;
}