I’m looking for an applescript that watches a folder for changes. Essentially http://homeusers.brutele.be/fbianchi/DA/index.htm which worked for os 9. However there isn’t an OS X version which I emailed the author about. What this script does is that it watches a folder usually the folder specified for web or server downloads. You set the bit rate and the seconds to check the folder. If the folder does not meet the criteria then the system is shutdown. Does anyone know of a program or script that could do this in os x?
Hmmm… Not sure, but may not be difficult re-create it:
property folderToWatch : alias "path:to:folder:"
global lastSize
set lastSize to 0
on idle
set newSize to size of (info for folderToWatch)
if newSize = lastSize then quit --> sample condition
set lastSize to newSize
return 10 --> check every 10 seconds
end idle
on quit
ignoring application responses
tell application "Finder" to shutdown
end ignoring
continue quit
end quit
tell application "Finder"
set newSize to size of folderToWatch
and add a ‘end tell’ somewhere before the return.
Also, I’d return a larger value than 10 seconds. The Finder can take a while to update and calculate the size of a folder and you run the risk of running too frequently.