• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question: Setting up a script to watch a folder in OS X?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Question: Setting up a script to watch a folder in OS X? (From: Roger_Jolly <email@hidden>)

  • Prev by Date: Re: Quick Quark Scripting Question
  • Next by Date: Re: Script preview
  • Previous by thread: Re: Question: Setting up a script to watch a folder in OS X?
  • Next by thread: Rebuild Microsoft Entourage database
  • Index(es):
    • Date
    • Thread