Re: Is there any way to simplify this?
Re: Is there any way to simplify this?
- Subject: Re: Is there any way to simplify this?
- From: Cal <email@hidden>
- Date: Sat, 20 Jan 2001 02:10:04 -0500
Can this script fragment be simplified? It bothers me that I had to type
the tell statement twice, and wonder if there's a way to avoid the
repition.
--Michelle
set longAgo to (current date) - 14 * days
try
tell application "Finder" to set thefilelist to every item ,
of thefilepath whose modification date is less than longAgo
on error
set the thefilepath to choose folder
tell application "Finder" to set thefilelist to every item ,
of thefilepath whose modification date is less than longAgo
end try
Well...it depends on whether you want the "choose folder" to pop up
in the Finder's execution layer, instead of in the execution layer
where the script is running. If so, you can put the tell block
around the try block:
set longAgo to (current date) - 14 * days
tell application "Finder"
try
set thefilelist to every item ,
of thefilepath whose modification date is less than longAgo
on error
set the thefilepath to choose folder -- this will happen in the Finder
set thefilelist to every item ,
of thefilepath whose modification date is less than longAgo
end try
end tell
As an aside, Michelle, this seems a little off to me, making the
assumption that *any* error you would get would require the user to
choose a folder.
Cal