I want all my newly downloaded torrent files to go in a separate folder “torrents”. I thought of creating folder action for this purpose. But if the file is being downloaded (incomplete file), it will still be moved to the “torrents” folder. This is not what I want.
Secondly, is there a way to have applescript move the file just before it is “opened” for the first time?
(Also, I have read that folder action slows down the mac because every time a file is added to the relevant folder, the script runs itself to see whether it must perform any action on it)
Thanks
What you would have to do is create a stay-open application. It would check the size of the folder on one pass, then after a time on the second pass it could check the size of the folder again. If the size is the same then you know no downloads are happening so you can move your file. If the size has changed then the download is still going on.
By the way, my torrent client has this feature built-in that when a download is complete you can have it moved to another folder. I’m using vuze but I think others have this feature too.
Thanks for the prompt reply.
I am not looking to move my download. I am trying to move my “.torrent” file (the one which is opened with a torrent client to start the torrent download)
Waiting for a file is straight-forward:
repeat with f in theItems
-- wait for the item to be all there
set was to 0
set isNow to 1
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 the folder
end repeat -- get next item f in the folder
and a stay-open “watcher” has this structure:
(*An "on idle" script, saved as a stay-open application will run at specified time intervals. Often used to "watch" something and respond.*)
on run
(*do setup - this runs when the application is started to set things up. It is not necessary to have an 'on run' handler because the on idle handler runs immediately after this anyway. If you want this to run all the time after every login, list it your startup items. You quit it from it's dock icon.*)
end run
(*'on idle' runs immediately following the 'run' handler if there is one, and thereafter on the interval specified in the return at the end. (An 'on run' handler is not required, so omit if there is no setup)*)
on idle
-- In this section, you do your script operations every interval
return xx -- do this every xx *seconds*.
end idle
on quit
(*do stuff - assumes you want to clean things up or save preferences or change properties before the program quits. This section runs only if the application is quit from the dock, or by any other means. It is not necessary to have one.*)
(*if there is an on quit handler, then 'continue quit' must be the last statement or the script will not stop! The presence of an 'on quit' handler 'grabs' the system command to stop, so it will not complete the quit process until notified to do so. 'continue quit' does that.*)
continue quit
end quit