Page 1 of 1

Help getting an Applescript to run

PostPosted: Mon Aug 25, 2014 8:32 am
by smeg head
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!

Re: Help getting an Applescript to run

PostPosted: Mon Aug 25, 2014 2:00 pm
by Mr_Noodle
It's possible that the script is timing out. It's a bad idea to have a script take too long since it pauses all processing on that folder. I'd nix that part.

Re: Help getting an Applescript to run

PostPosted: Mon Aug 25, 2014 9:35 pm
by smeg head
Good suggestion, but unfortunately when I comment out the delay the script still fails to run. Any other suggestions?

Re: Help getting an Applescript to run

PostPosted: Tue Aug 26, 2014 3:49 pm
by Mr_Noodle
Does it fail in the same way? What do the logs say?