Page 1 of 1
a script to add torrent files if they are in directory
Posted: Thu Jan 13, 2011 1:45 am
by B-80
So whenever I download a torrent file I put it in a different folder in my hard drive, and from time to time I have to format my main hard drive. I still have the old things I downloaded, but I was thinking of writing a script which will go through a folder full of .torrent files, check to see if the file/folder exists in a folder and then adds the corresponding .torrent file to transmission if it does as to not download the files again, but to let me seed what I have.
So first is there already something like this I am just missing, and where would I start here? How does transmission check to see if the information is in the folder? How would I go about adding mass files to transmission(in linux)? I am assuming there is a log file somewhere it stores everything it's seeding.
Re: a script to add torrent files if they are in directory
Posted: Thu Jan 13, 2011 4:07 am
by ijuxda
a script which will go through a folder full of .torrent files, check to see if the file/folder exists in a folder and then adds the corresponding .torrent file to transmission if it does
It should be possible to do this now, though the script may get a little involved. You can extract the relative path information from a torrent file using either
transmission-show or (perhaps less awkwardly) by parsing the file yourself, e.g. with the Bencode perl module. If the files from the torrent exist at the path where you expect, add the torrent with
Code: Select all
transmission-remote -a <the torrent file> --download-dir <that path>
Re: a script to add torrent files if they are in directory
Posted: Thu Jan 13, 2011 1:20 pm
by B-80
ijuxda wrote:a script which will go through a folder full of .torrent files, check to see if the file/folder exists in a folder and then adds the corresponding .torrent file to transmission if it does
It should be possible to do this now, though the script may get a little involved. You can extract the relative path information from a torrent file using either
transmission-show or (perhaps less awkwardly) by parsing the file yourself, e.g. with the Bencode perl module. If the files from the torrent exist at the path where you expect, add the torrent with
Code: Select all
transmission-remote -a <the torrent file> --download-dir <that path>
Okay cool, but how can I check to see if the torrent's data is already in the folder?
Re: a script to add torrent files if they are in directory
Posted: Thu Jan 13, 2011 11:10 pm
by ijuxda
how can I check to see if the torrent's data is already in the folder?
In bash and perl there is the expression
-f <file> that evaluates to true if the file exists.
I'm not sure if you're asking for help with transmission, or help with scripting in general. There are lots of resources available to help with the latter that are much better than this forum.
Re: a script to add torrent files if they are in directory
Posted: Fri Jan 14, 2011 1:47 am
by B-80
ijuxda wrote:how can I check to see if the torrent's data is already in the folder?
In bash and perl there is the expression
-f <file> that evaluates to true if the file exists.
I'm not sure if you're asking for help with transmission, or help with scripting in general. There are lots of resources available to help with the latter that are much better than this forum.
That transmission-remote thing was pretty much all I needed from transmission I guess.
I know how to check if a file is there, I don't know how to check a .torrent file to see if it's target is already in the directory. A finger in the right direction is all I need.
Re: a script to add torrent files if they are in directory
Posted: Fri Jan 14, 2011 10:51 pm
by ijuxda
I know how to check if a file is there, I don't know how to check a .torrent file to see if it's target is already in the directory. A finger in the right direction is all I need.
If you run
transmission-show on a torrent file, you get output along the lines of
Code: Select all
<stuff you do not need>
FILES
path/to/file1 (<size>)
path/to/file2 (<size>)
another/path/to/file3 (<size>)
<and so on>
Your script's job would be to ignore the output until it reaches the "FILES" section, then take in the paths stripping away the " (<size>)" part. Prefix the paths with the folder you are interested in, and test the resulting paths for existence. This is not the only way or possibly even the best way to accomplish your goal, but it should be usable.
I'm sorry if I did not immediately give you the answer and as such seemed less than willing to help, but I believe it does a better service to you in the long run to have you teach yourself the needed skills rather than if I were to write the script for you.