Help getting an Applescript to run

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Help getting an Applescript to run 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!
smeg head
 
Posts: 4
Joined: Tue May 27, 2014 2:04 am

Re: Help getting an Applescript to run 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.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Help getting an Applescript to run 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?
smeg head
 
Posts: 4
Joined: Tue May 27, 2014 2:04 am

Re: Help getting an Applescript to run Tue Aug 26, 2014 3:49 pm • by Mr_Noodle
Does it fail in the same way? What do the logs say?
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support