This script currently only supports relocation for single-file torrents.
(NOTE: qBT fundamentally cannot relocate multi-file torrents where multiple files have have been moved into multiple different target directories)
Groovy: Select all
def api = 'http://localhost:8080/api/v2'
def login = [username: 'YOUR_USERNAME', password: 'YOUR_PASSWORD']
// post HTML login form and receive login cookie
submit "$api/auth/login", login
// retrieve qBT torrent index
def info = curl "$api/torrents/info"
// find torrent for each processed file
args.eachWithIndex{ f, i ->
def torrent = info.find{ it.content_path == f.path }
if (torrent) {
submit "$api/torrents/renameFile", [hash: torrent.hash, oldPath: f.name, newPath: model[i].f.name]
submit "$api/torrents/setLocation", [hashes: torrent.hash, location: model[i].folder]
} else {
println "Torrent not found: $f"
}
}
// clear login cookie
submit "$api/auth/logout", [:]
Did you arrive here via a search?
You may prefer to use --action hardlink to simply have the same file twice at two or more file paths. No qBT relocation necessary.
You may prefer to use --action keeplink to replace the original file path with a symlink to the new file path. No qBT relocation necessary.