I have Hazel set up to copy some files to a disk "TRINITY" when it is inserted.
When there have been no activity on the target folder I wish to trigger the following AppleScript to softly eject the disk. I have tested that the folder is being recognised by successfully triggering a colour label change.
When I attempt to trigger the following AppleScript nothing happens. I have tried embedding the script and running it as a stand alone.
The script itself works fine when run from Applescript editor, waiting until the disk is idle and then ejecting it with the 'error' -128 (user cancelled).
Any help that could be offered would be appreciated.
#first we check the disk is actually mounted
tell application "Finder"
repeat
if disk "TRINITY" exists then
try
#then we 'try' to unmount if it isn't busy.
tell application "Finder" to eject (every disk whose name is "TRINITY" and ejectable is true and local volume is true)
#if the disk has been unmounted, we now exit the loop
if not disk "TRINITY" exists then exit repeat
#assuming the disk is busy and we repeating, a 5 minute delay keeps the script from taking over
delay 300
end try
else
#this stops the script from looping indefinitely
error number -128
end if
end repeat
end tell
#all done!