Scripting bittorrent?

Hi all,

I’m a complet applescript newbie, and was hoping to get some help on compling an applescript.
What I would like to do is create a folder for bittorrent downloads, and link this file to a bittorrent script (via folder actions,) the purpose being that when i drop a new torrent into this folder, it will automatically begin downloading…
I want to use a python version of bittorrent rather than the GUI version, as it is a little bit more flexable.
As far as i know the script should do the following -

  • open the terminal app
  • change directory to /applications/internet/bittorrent
  • execute "./ --max_uploads x --max_upload_rate xxx --min_port xxxx --max_port --responsefile xxxxxxxxx(being the file that i have dropped into the bittorrent folder - linked via folder actions to this script.)

I assume this is possible, and have been struggling away for a few days trying to figure this out…
Any help would be much appriciated.
Or if anyone knows of an alternative way to do this please let me know!

With thanks,

“do shell script” would be the applescript command to use. If you want to change the max upload count and rate and port numbers you can interactively get those numbers at the time of processing with a display dialog. If they don’t change, it’s easier. The things to remember about do shell script is to be sure that you are giving the command proper unix parameters (quote items that might have spaces) and use full paths to commands (like good shell scripting practice)

on adding folder items to this_folder after receiving these_items
--set your counts, rates and ports here if they may change
--then you have to concatenate the command using &
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set the responsefile to the quoted form of the POSIX path of this_item
                   --just in case the file name has spaces
		do shell script ("/full/path/to/directory/  ¬
                        --max_uploads x  --max_upload_rate xxx --min_port xxxx  ¬
                        --max_port --" & responsefile)
	end repeat
end adding folder items to

thank you for your prompt reply dennis!
i will sit down tomorrow and try to build something apporpriate.
your reply was very helpful, and (i think) has directed a complete newbie in the right direction!