| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Le 5 mars 07 à 21:27 Soir, John C. Welch a écrit:
On 3/5/07 13:59, "TjL" <email@hidden> wrote:
> I am trying to make a folder action for a folder where files get downloaded.
>
> When the download *completes* I want to move (or copy) the file to a
> different folder and then open the moved or copied version (if copy,
> open the copied version not the original.
>
> So far I have the move part down:
>
> on adding folder items to this_folder after receiving added_items
> tell application "Finder"
> repeat with aFile in added_items
> move aFile to folder "Downloads" of desktop
> end repeat
> end tell
> end adding folder items to
>
> but the open part doesn't seem to work. It doesn't seem to wait until
> the download completes perhaps?
Known issue. You have to loop-check the file sizes and compare.
I have a bit of canned code I use on a 3-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 --once the sizes match, the download is done
end repeat
--do other stuff here
end adding folder items to
Is it not faster to check for the file extension?
_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/email@hidden Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden
| References: | |
| >Re: Folder Action: Move and then open after download completes (From: Arnaud Nicolet <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.