Re: Folder Action Script: Detect a certain Volume in /Volumes
Re: Folder Action Script: Detect a certain Volume in /Volumes
- Subject: Re: Folder Action Script: Detect a certain Volume in /Volumes
- From: kai <email@hidden>
- Date: Sat, 14 May 2005 14:56:37 +0100
On Saturday, May 14, 2005, at 03:49 am, David C Andrews wrote:
Does one need a run-handler within a stay-open AS app?
Nope.
If a run handler exists, the script will execute any commands there -
and then move on to the idle handler. If no run handler is present, the
idle handler will kick in immediately. (The appropriate idle period
should come into effect only after the first iteration of the idle
handler.)
If not, couldn't the entire script suggested by Kurt be simplified as:
on idle
tell application "Finder" to set volume_list to the name of every
disk of desktop
if (volume_list contains search_string) then
-- do back up operations
end if
return 60 -- Time in seconds, will check every minute.
end idle
Yup. :-)
There's also a further refinement that might be worth considering here.
Let's assume that the user wants the script to check every minute until
the relevant backup disk is available. However, once the backup
operation has been performed, it may no longer be necessary to check
quite so regularly. If a backup is required only every hour (say), then
the idle period could be extended to reflect that:
--------
property search_string : "Backup" (* or whatever *)
on idle
tell application "Finder" to set backupNow ¬
to search_string is in name of disks
if backupNow then (* backup disk is available *)
-- do back up operations
hours (* check again after an hour *)
else (* backup disk is not available *)
minutes (* check every minute *)
end if
end idle
--------
(Incidentally, the 'of desktop' qualification shouldn't really be
necessary when checking for disks. In fact, since there's an option in
Finder Preferences to prevent disks from appearing on the desktop, its
inclusion might even compromise portability of the script.)
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden