Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Folder Action: Move and then open after download completes



***Before acting on this email or opening any attachment you are advised to read the disclaimer at the end of this email***
************************************

Not sure if this might help but someone once showed me this method which checks if the file can be opened for access:-

repeat 20 times
   try
       open for access file x -- if this succeeds, the file is not busy.
       close access result
       exit repeat
   on error -- file is busy
       delay 3 -- times it out in 1 minute
   end try
end repeat









On 5 Mar 2007, at 21:08, John C. Welch wrote:

On 3/5/07 14:39, "Arnaud Nicolet" <email@hidden> wrote:

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 theCompareSizetheBaseSize --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?

That only works if you only ever use Safari to download. Other applications/methods don’t use that convention. This doesn’t really delay things more than a few seconds, and unless you’re staring at the screen, you’re not really going to notice it.

--
"I think the the old joke "What do you call a bus full of lawyers driving over a cliff...a good start." Needs to be amended to a buss full of MacMacs.

The cluelessness of some of these people is astounding, but I guess when you live with your head up your own ass thinking it is Steve Jobs' ass, the bright lights of reality can be confusing."

"jkvt", YML List

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
 _______________________________________________
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





**********************************************************************
Communisis plc - registered no: 2916113 is a limited company registered in England and Wales and whose registered office is at Wakefield Road, Leeds, LS10 1DU.

Please Note: This e mail and its attachments contain only the opinions of the sender and do not necessarily reflect the policy (s) of the Communisis group in general.

Confidentiality: This e-mail and the contents of any attachments are intended for the named recipient(s) only and may be confidential. If you have received this e-mail and its contents in error you must take no action based on them, nor must you copy or show them to anyone. Please reply to this e-mail and highlight the error.

Warning: Although this e-mail and any attachments have been scanned for viruses, Communisis cannot guarantee that they are virus free. The Communisis group therefore accepts no responsibility for any loss or damage caused by transmission of this e-mail.
**********************************************************************

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
 _______________________________________________
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: "John C. Welch" <email@hidden>)



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.