Re: newbie question
Re: newbie question
- Subject: Re: newbie question
- From: "John C. Welch" <email@hidden>
- Date: Wed, 13 Oct 2004 17:42:09 -0500
Title: Re: newbie question
On 10/13/04 10:55 AM, "Paul Grossmann" <email@hidden> wrote:
> Is there a simple command I can use to make the script wait until the
> entire file has been received before opening? I was thinking of using
> the file size as the key, but that would limit me to that specific
> size.
Depends on your definition of "Easy".
The problem is, as of Panther, not all file copies set the finder busy flag. A lot of http downloads don’t. This was one that made me a little nuts when I was automating Virex scans with folder actions. My solution was to compare file sizes. When they stopped changing, the transfer was done. The basic routine is included below.
john
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 --once the sizes match, the download is done
--
"If God lived on earth, people would break his windows."
Jewish Proverb
_______________________________________________
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