• 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: Timing of folder action scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Timing of folder action scripts


  • Subject: Re: Timing of folder action scripts
  • From: "John C. Welch" <email@hidden>
  • Date: Thu, 16 Mar 2006 09:03:54 -0600
  • Thread-topic: Timing of folder action scripts

Title: Re: Timing of folder action scripts
On 3/16/06 07:48, "Gary Tate" <email@hidden> wrote:

>> One of those glitches involves the timing of the scripts. Editors  
>> often
>> download files directly into the "hot" folders, so II've written an
>> 80-second delay into each script.
>
> I do something slightly different. I enter a loop and check the size  
> of the file. Once it stops growing you know it's all there. This is  
> probably safer than a delay as the file could take longer, or much  
> less than 80 seconds.

That's what I do too. The first thing in the folder action is a size check that runs on a three second delay:

on adding folder items to theFolder after receiving theAddedItems
   tell application "Finder" to set theFolderName to name of theFolder
   repeat with x in theAddedItems
       set theFileInfo to info for x --get info for the downloading file(s)
       set theBaseSize to size of theFileInfo --get initial size
       delay 3 --wait 3 seconds
       set theFileInfo to info for x --get info again
       set theCompareSize to size of theFileInfo --get a newer size
       repeat while theCompareSize ≠ theBaseSize --if they don't equal, loop until they do
           set theBaseSize to theCompareSize --new base size
           delay 3 --wait three seconds
           set theFileInfo to info for x --get info
           set theCompareSize to size of theFileInfo --get a newer size
       end repeat
   end repeat
    --do actual script work
       
    
end tell
end
adding folder items to

--
We're surrounded. That simplifies the problem.
- Chesty Puller, USMC
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Timing of folder action scripts (From: Gary Tate <email@hidden>)

  • Prev by Date: Illusrator CS2 Align Page Items
  • Next by Date: Re: List Folders bug?
  • Previous by thread: Re: Timing of folder action scripts
  • Next by thread: Creating raw applevents in cocoa
  • Index(es):
    • Date
    • Thread