Hello
I think you have stepped on a land mine set by OSX 10.6.
There's a fatal bug in Apple Event Manager in 10.6 such that one event in every 65535 events will be lost and never be replied, which will result in Apple Event timeout error on sender. This bug has been reported shortly after the 10.6 release and has not yet been fixed as of 10.6.2.
In your current script, you're continuously sending event to Finder and sooner on later send an event with the specific event id that is doomed to be lost. Judging from the time till you see the time out error, that is 10 min, you're at most sending 65535 / 600 = 109.225 events / sec to Finder. You can reduce the number of events by inserting some delay, e.g. 'delay 1' in your repeat loop but it can only defer the failure.
cf.
Re: Timed Out (Silence)
http://lists.apple.com/archives/applescript-users/2009/Oct/msg00117.html
Re: spurious timeout on nth Apple event on Snow Leopard
http://lists.apple.com/archives/applescript-users/2009/Nov/msg00041.html
---
A better way to achieve your task would be to let a launchd agent watch the file.
A recipe is as follows.
1) Save a compiled script in :
~/Library/Scripts/launchd/watchdog.1.scpt
with contents :
--SCRIPT
-- Here put your script that is to be triggered when the file is modified.
-- e.g.
tell application "System Events"
display dialog "The file is modified." giving up after 10
end tell
--END OF SCRIPT
2) Save a UTF-8 plain text file in :
~/Library/LaunchAgents/watchdog.1.plist
with contents :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>watchdog.1</string>
<key>Disabled</key>
<false/>
<key>Program</key>
<string>/usr/bin/osascript</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/USER_NAME/Library/Scripts/launchd/watchdog.1.scpt</string>
</array>
<key>WatchPaths</key>
<array>
<string>POSIX_PATH_TO_THE_FIILE</string>
</array>
</dict>
</plist>
*Change
USER_NAME to your user name and
POSIX_PATH_TO_THE_FIILE to the POSIX path to the file to be watched.
3) Issue the following command in Terminal to load the launchd agent :
launchctl load ~/Library/LaunchAgents/watchdog.1.plist
Or
3a) Log-out and re-log-in to load the launchd agent.
*The name 'watchdog.1.plist' and 'watchdog.1.scpt' and the script's location '~/Library/Scripts/launchd/' are mere examples. You may change them as you see fit.
cf.
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/m an5/launchd.plist.5.html
http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/m an1/launchctl.1.html
Good luck,
H
Message was edited by: Hiroto (fixed typo)