Re: Timing of scripts
Re: Timing of scripts
- Subject: Re: Timing of scripts
- From: email@hidden
- Date: Thu, 16 Mar 2006 15:49:07 -0500
Thanks Gary and John! The size check definitely is better than a
straight delay. I'll implement that for sure.
I do still wonder what mechanism controls which folder script runs first
when multiple folder scripts are triggered simultaneously.
Thanks again,
Jim
------------------------------
Message: 2
Date: Thu, 16 Mar 2006 13:48:59 +0000
From: Gary Tate <email@hidden>
Subject: Re: Timing of folder action scripts
To: applescript-users <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
On 15 Mar 2006, at 21:49, 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.
------------------------------
Message: 5
Date: Thu, 16 Mar 2006 09:03:54 -0600
From: "John C. Welch" <email@hidden>
Subject: Re: Timing of folder action scripts
To: "AppleScript User's List" <email@hidden>
Message-ID: <C03EDA7A.AF51%email@hidden>
Content-Type: text/plain; charset="iso-8859-1"
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
--
_______________________________________________
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