Re: FindFile
Re: FindFile
- Subject: Re: FindFile
- From: Michelle Steiner <email@hidden>
- Date: Mon, 4 Dec 2000 11:33:08 -0800
On 12/4/00 8:33 AM, Joe <email@hidden> wrote
>
I'm trying to write a script that will find all files in a certain folder
>
that have creation dates that are older than 5 days before the current date.
>
>
I've tried writing the script using the FindFile addition but I keep getting
>
this errror " because *Ox//* the original item cannot be found 32768029"
Here's something I wrote to move files to the trash if they're older than
14 days, but to always keep the most recent 14 files; it works under Mac
OS 9 but I don't know whether it will work under older versions of the OS.
--Michelle
property thefilepath : " "
--Keep 14 days of files or 14 files, whichever is greater.
set daysToKeep to 14
set Maxfiles to daysToKeep
set counter to 0
try
set thefilelist to list folder thefilepath without invisibles
on error
set the thefilepath to choose folder
set thefilelist to list folder thefilepath without invisibles
end try
if (count thefilelist) is greater than Maxfiles then
repeat with thefile in thefilelist
set anotherfilelist to list folder thefilepath without invisibles
if (count anotherfilelist) > Maxfiles then
exit repeat
else
set thetestfile to alias ((thefilepath & thefile) as text)
set thefiledate to the modification date of (info for thetestfile)
set theDateDelta to (current date) - thefiledate
if theDateDelta > daysToKeep * days then
tell application "Finder" to delete thetestfile
set counter to counter + 1
end if
end if
end repeat
end if
----------------------------------------------------------------------
| Michelle Steiner | Hard as it may be to believe, my |
| email@hidden | life has been based on a true story. |
----------------------------------------------------------------------