|
Next: how to disconnect macbook video display
|
| Author |
Message |
External

Since: Mar 18, 2008 Posts: 6
|
(Msg. 1) Posted: Fri Dec 12, 2008 2:33 pm
Post subject: Folder Action & temporary files Archived from groups: alt>comp>lang>applescript (more info?)
|
|
|
Hello,
i am trying to write a Folder Action AppleScript which should attached
to my download folder.
In this applescript-code i do several modifications i.e. i
unquarantine the files, color them using labels etc...
But i realize one big problem which is related (at least i tihnk so)
with running downloads and temporary files created by the browsers
(safari & firefox)
the folder action is triggered before the download had finished and i
guess folder actions don't get retriggered if a temp file is renamed
to its final filename, but some of the actions (like file-renaming)
can only be done if the file-transfer is done.
so lets look on my code:
property DELAY_TIME_SECONDS : 5 -- How long to wait between checking
file size.
on adding folder items to thisFolder after receiving theItems
repeat with f in theItems
set oldSize to 0
set newSize to -1
-- When newSize equals oldSize, it means the copy is complete
because the size hasn't changed.
repeat while newSize ≠ oldSize
-- Get the file size.
set oldSize to size of (info for f)
delay DELAY_TIME_SECONDS
-- Sample the size again after delay for comparison.
set newSize to size of (info for f)
end repeat
--
-- Do your processing here on file f.
-- im just trying to show a small dialog here where my actions/
modifications should happen for the file
display dialog "download finished"
--
-- thats where my processing should start for each
file
end repeat
-- Or start processing here to wait for all files to be complete.
end adding folder items to
END
I am wondering if my guess with the temorary files is causing my
problems as i guess my applescriot code itself should work.
Would be great if someone else could give me a hint regarding this
problem
Best regards
fidel |
|
| Back to top |
|
 |  |
External

Since: Mar 18, 2008 Posts: 6
|
(Msg. 2) Posted: Fri Dec 12, 2008 3:11 pm
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hi Dave,
may i ask why you suggest not to use Folder Actions ?
Is it that unstable / broken ?
Thank you for the fast response.
Best regards
fidel |
|
| Back to top |
|
 |  |
External

Since: May 31, 2006 Posts: 850
|
(Msg. 3) Posted: Fri Dec 12, 2008 4:36 pm
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |
External

Since: May 31, 2006 Posts: 850
|
(Msg. 4) Posted: Fri Dec 12, 2008 7:30 pm
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 1218
|
(Msg. 5) Posted: Fri Dec 12, 2008 7:44 pm
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <121220081930039107%dave@N_O_T_T_H_I_Sbalderstone.ca>,
Dave Balderstone <dave RemoveThis @N_O_T_T_H_I_Sbalderstone.ca> wrote:
> In article
> <8a2522be-9125-4ef9-9cad-94d19851653f RemoveThis @u18g2000pro.googlegroups.com>,
> Florian <fidel RemoveThis @vido.info> wrote:
>
> > may i ask why you suggest not to use Folder Actions ?
> > Is it that unstable / broken ?
>
> I've found them unreliable.
Strange. They've always worked fine for me.
--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.
JR |
|
| Back to top |
|
 |  |
External

Since: May 31, 2006 Posts: 850
|
(Msg. 6) Posted: Fri Dec 12, 2008 8:03 pm
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |
External

Since: Dec 13, 2008 Posts: 1
|
(Msg. 7) Posted: Sat Dec 13, 2008 7:08 am
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hi Florian,
On 12/12/2008 23:33:10 Florian <fidel.DeleteThis@vido.info> wrote:
i am trying to write a Folder Action AppleScript which should attached to
> my download folder. In this applescript-code i do several modifications
> i.e. i unquarantine the files, color them using labels etc...
> But i realize one big problem which is related (at least i tihnk so) with
> running downloads and temporary files created by the browsers (safari &
> firefox)
> the folder action is triggered before the download had finished and i
> guess folder actions don't get retriggered if a temp file is renamed to
> its final filename, but some of the actions (like file-renaming) can only
> be done if the file-transfer is done.
I don't think the file really is renamed. I think once the download completes (Name.download file) a new file is created with the contant and the name of the downloaded file "Name".
I you have a download file selected in the Finder when it is downloading, that selection will be lost when the download finishes and the new file is created, replacing the download file...
May you should try triggering only on (the creation of) files that have no .download extension. Download extension files can have other "problems" as well.
If you do not OK the Safari message "This file is an application..." (with HTML files), this file download will not finish, and the final file/finale name will not be created...
Even cancelling such a download leaves the already downloaded part of a downloadfile (file.download) intact. This has te be removed manually...
Hans Besjes
> so lets look on my code:
> property DELAY_TIME_SECONDS : 5 -- How long to wait between checking file
> size.
> on adding folder items to thisFolder after receiving theItems repeat with
> f in theItems set oldSize to 0 set newSize to -1 -- When newSize equals
> oldSize, it means the copy is complete because the size hasn't changed.
> repeat while newSize ≠ oldSize -- Get the file size. set oldSize to
> size of (info for f) delay DELAY_TIME_SECONDS -- Sample the size again
> after delay for comparison. set newSize to size of (info for f) end
> repeat -- -- Do your processing here on file f. -- im just trying to show
> a small dialog here where my actions/ modifications should happen for the
> file display dialog "download finished" -- -- thats where my processing
> should start for each file end repeat -- Or start processing here to wait
> for all files to be complete. end adding folder items to
> END I am wondering if my guess with the temorary files is causing my
> problems as i guess my applescriot code itself should work.
> Would be great if someone else could give me a hint regarding this problem
> Best regards fidel |
|
| Back to top |
|
 |  |
External

Since: Nov 05, 2007 Posts: 1218
|
(Msg. 8) Posted: Sat Dec 13, 2008 9:46 am
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <121220082003410208%dave@N_O_T_T_H_I_Sbalderstone.ca>,
Dave Balderstone <dave DeleteThis @N_O_T_T_H_I_Sbalderstone.ca> wrote:
> In article <jollyroger-7ACF2E.19442912122008 DeleteThis @news.individual.net>,
> Jolly Roger <jollyroger DeleteThis @pobox.com> wrote:
>
> > In article <121220081930039107%dave@N_O_T_T_H_I_Sbalderstone.ca>,
> > Dave Balderstone <dave DeleteThis @N_O_T_T_H_I_Sbalderstone.ca> wrote:
> >
> > > In article
> > > <8a2522be-9125-4ef9-9cad-94d19851653f DeleteThis @u18g2000pro.googlegroups.com>,
> > > Florian <fidel DeleteThis @vido.info> wrote:
> > >
> > > > may i ask why you suggest not to use Folder Actions ?
> > > > Is it that unstable / broken ?
> > >
> > > I've found them unreliable.
> >
> > Strange. They've always worked fine for me.
>
> Strange. They haven't for me.
>
> What have you used them for? That's probably the difference.
Well, here's one use case:
I use MT-NewsWatcher's "Shared Newsrc" feature, which stores my
subscription and group status information in a "newsrc" file on my FTP
server here at home. I also keep a copy of the Filters.xml file exported
from MT-NewsWatcher there, as well as a text file containing my Usenet
signature. I have a folder called "Upload News Stuff" with a folder
action attached that automatically uploads these files to the same
location on the FTP server whenever I drop file them it. It works great.
I've used folder action scripts to do things like convert images from
one format to another, and things like that in the past as well.
--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.
JR |
|
| Back to top |
|
 |  |
External

Since: May 31, 2006 Posts: 850
|
(Msg. 9) Posted: Sat Dec 13, 2008 10:22 am
Post subject: Re: Folder Action & temporary files [Login to view extended thread Info.] Imported from groups: per prev. post (more info?)
|
|
|
This message is not archived |
|
| Back to top |
|
 |  |