Move already (i.e. not new) completed files in rtorrent
I've been using rtorrent for a while with a single directory. Now I figured out it was possible to use different directories and even to move completed downloads elsewhere, so according to the rtorrent wiki I edited my .rtorrent.rc as follow :
# Download directory
directory = /Medias/torrents/
# Watching directories
schedule = watch_directory_1,5,60,"load_start=/path/to/dl/dir1/*.torrent,d.set_custom1=/path/to/done/dir1"
schedule = watch_directory_2,5,60,"load_start=/path/to/dl/dir2/*.torrent,d.set_custom1=/path/to/done/dir2"
# On completion, move the torrent to the directory from custom1.
system.method.set_key = event.download.finished,move_complete,"d.set_directory=$d.get_custom1= ;execute=mv,-u,$d.get_base_path=,$d.get_custom1="
It seems to work for new torrents. However I have a bunch of completed files I have already downloaded before to split directories, and for them it does not work : if I delete their file in the session directory, rtorrent will check the hash but won't move them, and if I move them by myself rtorrent won't see them and will try to redownload them.
So how can I tell rtorrent either to move them or that they are in another directory ?
Thanks.
Ok, just figured this out. Within rtorrent you can open a command line using Ctrl+X. You can do many things from there (I guess this is basic rtorrent management), like printing things (print=$variable=
, e.g. print=$d.get_directory=
), executing commands (execute=command
), or setting variables (variable=newvalue
).
From this prompt you can move the finished torrent elsewhere, BUT note that it is neither necessary nor sufficient (see below). For instance, using the example from the .rtorrent.rc file given in the original question :
execute=mv,-u,$d.get_base_path=,$d.get_custom1=
However, this command will prevent rtorrent from continuing to seed the torrent, which is why it is not sufficient. In order to continue seeding, you should, still from this command prompt, set the download directory for this torrent to the new location :
d.set_directory=/path/to/new/directory/
Finally, the execute
command is not necessary : you can move the torrent the way you want (i.e. outside rtorrent), as long as you set the new directory as explained above.
After that it may be necessary to reopen the torrent (if it's marked as [CLOSED]) using Ctrl+R.
as bash script:
edit, when mv -u $old $new
fails, then the whole command fails.
i ended up leaving rTorrent for qBitTorrent.
#!/bin/bash
#
# move files in rTorrent
# with rtxmlrpc from pyrocore
#
# 1. select all torrents from view $view
# 2. print old d.base_path
# 3. set new d.directory
# torrent is closed
# d.base_path is still old d.base_path
# 4. move old files to new dir
# 5. open torrent
# d.base_path is set to new path
# 6. save output to text file
view='complete'
dest="/home/rtorrent/$view/"
# escape double quotes
dest=$(echo "$dest" | sed 's/"/\\"/g')
rtxmlrpc d.multicall2 '' "$view" \
'd.base_path=' \
"d.directory.set=\"$dest\"" \
"execute=mv,-u,(d.base_path),\"$dest\"" \
'd.open=' \
| tee rtxmlrpc.$(date +%s).txt