Re: Question: Setting up a script to watch a folder in OS X?
Re: Question: Setting up a script to watch a folder in OS X?
- Subject: Re: Question: Setting up a script to watch a folder in OS X?
- From: Roger_Jolly <email@hidden>
- Date: Mon, 24 Jun 2002 14:02:31 +0200
>
> A very simple question: Does anybody have examples of a script that can
>
> 'watch' a folder, and perform tasks when files are dropped into it, then
>
> output the result to a second folder? (I guess this sounds like a job for
>
> Folder Actions, but the script needs to be capable of running under OS X)
>
In short what I've done is setting up a loop in which the Finder reads out
>
the selection, or in your case the contents of a folder, storing it in a
>
record. The next time round compare it with precious saved record to see if
>
there are changes. If so, take action.
After some thinking (which I should of course do before posting) I realised
you might want something easier, like using an idle handler.
----
on idle
tell application "Finder" to set TheFiles to every item of FolderToWatch
repeat with TheFile in TheFiles
Process(TheFile)
tell application "Finder" to move TheFile to AnotherFolder
end repeat
end idle
----
(Replacing of course FolderToWatch, Process(TheFile) and AnotherFolder with
what you need.)
If you need quicker responses than the 30 seconds default rate of the idle
handler, just put a smaller number as last statement in the idle handler. Or
do it explicit with a return statement like
----
on idle
-- some code
return 15 -- will set the idle handler to repeat every 15 seconds
end idle
----
Roger Jolly
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.