
jr
Novice
Apr 3, 2000, 12:39 PM
Post #1 of 4
(375 views)
|
|
Deleting Old Files
|
Can't Post
|
|
I have a directory that stores temporary images prior to a full posting of information, I wrote a script that should delete any images older than one day, but it isn't doing it. I can't even get it to spit an error message out to me... Since I am currently doped up on cold medicine, I don't think my brain is working correctly, if at all...so any help would be apreciated: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> sub image_temp_clean { $imagetempdays = 1; opendir THEDIR, "$imagetempdir" | | die "Unable to open directory: $!"; @allimage = readdir THEDIR; closedir THEDIR; foreach $file (sort { int($b) <=> int($a) } @allimage) { if (-T "$imagetempdir/$file") { $imagetempdir2 = "$imagetemp/$file"; ($imagedate) = (stat($imagetempdir2))[9]; $imagedate =~ s/\D//g; $currenttime = time; $comparetime = ($currenttime - ($imagetempdays * 86400)); if ($comparetime > $imagedate) { unlink "imagetempdir/$file" if (($file ne "index.html") && ($file ne ".htaccess")); } } } } </pre><HR></BLOCKQUOTE> Thanks in advance
|