Re: Folder Actions technical questions
Re: Folder Actions technical questions
- Subject: Re: Folder Actions technical questions
- From: "Adam Bell" <email@hidden>
- Date: Mon, 3 Apr 2006 19:20:22 -0300
Couple of comments, Mark;
You grab the old text item delimiters, but you don't restore them.
This can all be one giant tell application "Finder" block with the end tell just before the return 5.
You can save some steps in your wait. I use this:
-- wait for the item to be all there or fully unzipped or whatever
set {was, isNow} to {0, 1} -- get right into the loop
repeat while isNow ≠ was
set was to size of (info for f)
delay 2 -- longer if getting the item is slow
set isNow to size of (info for f)
end repeat
-- Now do stuff to another f in thisFolder
On 4/3/06, Mark Siple <email@hidden> wrote:
All:
Thank you very much for your help. I've converted my folder action into an
idle applet that seems to work well (though I haven't thoroughly tested it
yet!!)
Thanks especially to John C. Welch for including the code for looping until
the file is complete. I was thinking along those lines but hadn't actually
started to code it. Your sample made it nearly a drag and drop affair. ;-)
Here's the relevant part in the hopes of helping someone else:
on idle
tell application "Finder" to set foundfiles to (count files in folder
((startup disk as string) & "Library:FTPServer:FTPRoot:FromServer:"))
if foundfiles is greater than 0 then
-- grab list of files for processing
tell application "Finder" to set imagefiles to files in folder
((startup disk as string) & "Library:FTPServer:FTPRoot:FromServer:")
--save Applescript's current delimiters
set olddelim to AppleScript's text item delimiters
repeat with zipfullpath in imagefiles
-- extract folder and file from full path
tell application "Finder" to set zippath to container of
zipfullpath as string
set AppleScript's text item delimiters to ":"
set zipfile to text item -1 of (zipfullpath as text)
--loop until file transfer is complete
set fileinfo to info for alias (zippath & zipfile)
set originalsize to size of fileinfo
delay 3
set fileinfo to info for alias (zippath & zipfile)
set newsize to size of fileinfo
repeat while originalsize ‚ newsize -- loop until same size
set originalsize to newsize
delay 2
set fileinfo to info for alias (zippath & zipfile)
set newsize to size of fileinfo
end repeat
[ DO A BUNCH OF OTHER PROCESSING OF THE FILE(S) ]
end if
return 5
end idle
Compile and save as an application but be sure to check the STAY OPEN box.
Mark.
-----
Mark Siple <email@hidden>
Systems Administrator
The Columbus Dispatch
"Never ask a man what sort of computer he drives.
If it's a Mac, he'll tell you.
If not, why embarrass him?" -- Tom Clancy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (
_______________________________________________
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