I’m trying to create an applescript that ultimately is a folder action attached to the “Downloads” folder. Preferably, I’d like the script to watch for the .download extension to be added or removed, and trigger certain things when this occurs, signaling that a download has begun or finished, without going to the toolbar of safari to check. The script, in plain english, should go like this:
tell application “Finder”
when file extension “.download” is added to this_folder, say “download has begun.”
when a file with extension “.download” is removed from this folder, say “download is complete.”
I’m just not sure if there is applescript to do this.
thanks so much,
You should attach 2 folder actions to Downloads folder. You can do it with RightClick on Download Folder —> Services —> Folder Actions Setup… and so on. To say “Download begun” is the following folder action:
on adding folder items to theAttachedFolder after receiving theNewItems
tell application "Finder" to if name of (item 1 of theNewItems) ¬
contains ".torrent" then say "One download has begun"
end adding folder items to
NOTE: In the torrent client’s preferences you should set “Automatically load .torrents” to Downloads folder.
And to say “One download is complete” is the following folder action:
on removing folder items from theAttachedFolder after losing theRemovedItems
tell application "Finder" to if name of (item 1 of theRemovedItems) ¬
contains ".torrent" then say "One download is complete"
end removing folder items from
NOTE: In the torrent client’s preferences you should set “Move .torrents for finished jobs” to some other folder of your computer. The only important is this folder to be not Downloads folder. For example, put the Trash folder
NOTE: some downloads (torrents, for example) may do not have extension at all. So, it is better to filter with the download name.
LAST NOTE: to use Safari as client you should set “Remove download list items” to “Upon successful download”. The searching method should be changed from “.torrent” to some other criteria. For example, with UTI of downloaded file. Or to “.download” as want the OP.