Re: Moving large PDF files with Applescript
Re: Moving large PDF files with Applescript
- Subject: Re: Moving large PDF files with Applescript
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 31 Mar 2009 11:03:04 -0400
If you can control the process writing the files, one option is to
have it write to a temporary filename in the folder, then rename it
when done writing, where the temp names and final names follow
different patterns and the folder action only operates on files
matching the final name pattern. For instance, write to a .tmp and
then rename to .pdf and have the action only operate on files whose
name extension is "pdf".
Only viable if you control the producer as well as the consumer, but
avoids the busy loop spinning on the file size, and is more reliable
in the face of long delays..
On 3/31/09, John C. Welch <email@hidden> wrote:
> On 3/31/09 10:21 AM, "Mielke, Gary R (CGC)" <email@hidden> wrote:
>
>> We are currently using the following script to watch a Source Folder and
>> move
>> files into other folders. One problem that we are having is that when the
>> files are being copied into the source folder, the script will try and
>> grab
>> the file before it is completely copied. Is there other ways to write the
>> Applescript to watch for a file to make sure the file is completely copied
>> before moving or is there another solution that would work better than
>> Applescript? The files that we are watching are PDF files. Any
>> suggestions,
>> thoughts or ideas would be appreciated!
>
> Ed¹s solution is what I did for this, with slightly different syntax. You
> basically have to set a size comparison loop. The one I did, for the first
> versions of Virex on Mac OS X was:
>
> repeat with x in added_items
> 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
>
>
> But the general idea is the same, since there¹s no reliable way to see if a
> file is done being moved/copied into a folder from the finder et al.
> --
> "We ain't making no goddamn corn flakes here."
> Col. Charlie Beckwith, founder of Delta Force
>
>
--
Sent from my mobile device
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden