Re: Delete contents of 'server' folder on shutdown.
Re: Delete contents of 'server' folder on shutdown.
- Subject: Re: Delete contents of 'server' folder on shutdown.
- From: Joe Szedula <email@hidden>
- Date: Thu, 31 May 2001 11:52:34 -0500
>
I have written this script to delete the contents of the 'server' folder
>
within the system folder for our media/scanning station.
>
>
tell application "Finder"
>
activate
>
select every item of container window of folder "Servers" of folder
>
"System Folder" of startup disk
>
delete selection
>
empty trash
>
end tell
>
>
I have placed it inside the 'shutdown' items folder within the system folder
>
as a way of running it automatically. Basically the number of server alias
>
grows to several hundred over the course of a few weeks as our designs log
>
into the server to transfer their scans, etc. and I needed a way of cleaning
>
the folder out periodically.
>
>
It runs faithfully and does what it's supposed to, however it aborts the
>
shutdown/restart process. Is this standard behaviour? What do I do in the
>
script to ensure that the shutdown/restart process proceeds normally?
>
I had the same problem a while back when I wrote a shutdown/restart
script. I seem to recall the problem may be:
1. The "activate"
2. Launching an application with your Applescript. Are you using "Speed
Doubler" or "Copy Doubler"?
I use the following in my Shutdown/Restart script because I use "Speed
Doubler" and it launches because I have the "Intercept Finder Apple
Events" checked:
property DefaultFinish : "Shut Down"
on DoShutdown()
try
set myTimeout to 10
set ShutdownPrompt to "Proceed with Shut Down or Restart ?"
set ShutdownButtons to {"Shut Down", "Restart"}
activate
set ButtonReturned to button returned of (display dialog ,
ShutdownPrompt buttons ShutdownButtons ,
giving up after myTimeout default button DefaultFinish)
if (ButtonReturned = "") then
set ButtonReturned to DefaultFinish -- result of timeout
else
set DefaultFinish to ButtonReturned -- make current selection the new
default
end if
on error
set ButtonReturned to DefaultFinish -- result of error
end try
-- perform shutdown/restart
tell application "Finder"
if ButtonReturned = "Shut Down" then
shut down
else
restart
end if
end tell
end DoShutdown
Joe Szedula
Email: email@hidden