Skip to main content

qBt Migrate

Python

This tool changes the paths of existing torrents in qBittorrent in a bulk fashion. It can also convert slashes when migrating between Windows and Linux/Mac.

Demo

Usage

ALWAYS ensure qBittorrent is closed before running qbt_migrate. Either quit through File -> Exit, task tray icon, or task manager for your system.

Install from PyPi using pip, or jump to Examples for Docker

pip install qbt_migrate

Run the script and follow prompts or use CLI arguments with command qbt_migrate

usage: qbt_migrate [-h] [-e EXISTING_PATH] [-n NEW_PATH] [-r] [-t {Windows,Linux,Mac}] [-b BT_BACKUP_PATH] [-s] [-l {DEBUG,INFO}] [-v]

options:
  -h, --help            show this help message and exit
  -e EXISTING_PATH, --existing-path EXISTING_PATH
                        Existing root of path to look for.
  -n NEW_PATH, --new-path NEW_PATH
                        New root path to replace existing root path with.
  -r, --regex           Existing and New paths are regex patterns. (Capture groups recommended).
  -t {Windows,Linux,Mac}, --target-os {Windows,Linux,Mac}
                        Target OS (converts slashes). Default will auto-detect if conversion is needed based on existing vs new.
  -b BT_BACKUP_PATH, --bt-backup-path BT_BACKUP_PATH
                        BT_backup Path Override.
  -s, --skip-bad-files  Skips bad .fastresume files instead of exiting. Default behavior is to exit.
  -l {DEBUG,INFO}, --log-level {DEBUG,INFO}
                        Log Level, Default is INFO.
  -v, --version         Prints the current version number and exits.

By default, everything happens in the BT_backup directory defined by the OS the script is running on. Override BT_backup path if needed.

Default BT_backup paths:

  • Windows: %LOCALAPPDATA%/qBittorrent/BT_backup
  • Linux/Mac: $HOME/.local/share/data/qBittorrent/BT_backup
  • Docker: /config/qBittorrent/BT_backup

A backup zip archive is automatically created in the BT_backup directory.

Examples

Assuming all of our torrents are in X:\Torrents when coming from Windows, or /torrents when coming from Linux/Mac

NOTE: When running qbt_migrate on a Linux/Mac machine, Windows paths will require double \. Ex. C:\\Users\\user\\Downloads\\Torrents

NOTE: Take note of trailing slash replacement when changing from Windows <-> Linux. -e X:\ -n /torrents will result in /torrentsxxxxx, not /torrents/xxxxx. The correct pattern for this would be -e X: -n /torrents or -e X:\ -n /torrents/.

qbt_migrate -e X:\ -n Z:\ -t Windows  # Windows to Windows (Drive letter change)
qbt_migrate -e X:\Torrents -n X:\NewDir\Torrents -t Windows  # Windows to Windows (Directory Change)
qbt_migrate -e X:\Torrents -n Z:\NewDir\Torrents -t Windows  # Windows to Windows (Drive letter change with directory change)
qbt_migrate -e X: -n /torrents -t Linux  # Windows to Linux/Mac (converts slashes)  # When running on Linux machine \\ is needed for Windows Paths  # Note Trailing Slash
qbt_migrate -e X:\Torrents -n /torrents -t Linux  # Windows to Linux/Mac (converts slashes)  # When running on Linux machine \\ is needed for Windows Paths
qbt_migrate -e X:\\Torrents -n /torrents -t Linux  # Windows to Linux/Mac (converts slashes)  # When running on Linux machine \\ is needed for Windows Paths

qbt_migrate -e /torrents -n /new/path/for/torrents  # Changes torrent root path on Linux/Mac
qbt_migrate -e /torrents -n Z:\Torrents -t Windows  # Linux/Mac to Windows (converts slashes)
qbt_migrate -e /torrents -n Z:\\Torrents -t Windows  # Linux/Mac to Windows (converts slashes)  # When running on Linux machine \\ is needed for Windows Paths

# Adavanced Usage with RegEx
# Example would replace /some/test/with/a/path with /test/matched/path
qbt_migrate -r -e /some/(\w+)/.*$ -n \1/matched/path -t Linux  # Matches using regex patterns and replaces using capture groups.
qbt_migrate --regex -e /some/(\w+)/.*$ -n \1/matched/path -t Linux  # Matches using regex patterns and replaces using capture groups.

Docker

You can also run this tool with Docker if you don't have Python, or don't want to install the package to your system directly. The BT_backup path is automatically overridden to /tmp/BT_backup, so mount your BT_backup there.

NOTE: When running qbt_migrate Docker image on a Linux/Mac machine, Windows paths will require double \. Ex. C:\\Users\\user\\Downloads\\Torrents

The Docker image has all functionality as the pip install, following the same arguments/patterns listed in the above examples.

For example, mounting in the default BT_backup path on a Windows machine running Docker

docker run -v %LOCALAPPDATA%/qBittorrent/BT_backup:/tmp/BT_backup jslay88/qbt_migrate -e X:\ -n Z:\  # Windows to Windows (Drive letter change)
docker run -v %LOCALAPPDATA%/qBittorrent/BT_backup:/tmp/BT_backup jslay88/qbt_migrate -e X:\Torrents -n X:\NewDir\Torrents -t Windows  # Windows to Windows (Directory Change)
...

Mounting in the default BT_backup path on a Linux/Mac machine running Docker

docker run -v $HOME/.local/share/data/qBittorrent/BT_backup:/tmp/BT_backup jslay88/qbt_migrate -e X:\ -n Z:\  # Windows to Windows (Drive letter change)
docker run -v $HOME/.local/share/data/qBittorrent/BT_backup:/tmp/BT_backup jslay88/qbt_migrate -e X:\Torrents -n X:\NewDir\Torrents -t Windows  # Windows to Windows (Directory Change)
...

If for some reason you wanted to override BT_backup path from /tmp/BT_backup within the container, simply set environment variable BT_BACKUP_PATH on the container to where you will be mounting in.

The -e for environment variable override must go before the image jslay88/qbt_migrate as the -e after the image is for --existing-path

docker run -v %LOCALAPPDATA%/qBittorrent/BT_backup:/opt/qbt_migrate/fastresume -e BT_BACKUP_PATH=/opt/qbt_migrate/fastresume jslay88/qbt_migrate -e X:\ -n Z:\  # Windows to Windows (Drive letter change)
...

You can also clone this repository, build the image, and run your own built image

docker build . -t qbt_migrate
docker run -v %LOCALAPPDATA%/qBittorrent/BT_backup:/tmp/BT_backup qbt_migrate -e X:\ -n Z:\  # Windows to Windows (Drive letter change)
...

Python Module

This project has also been built to be modular and used as a Python Module. If you feel like utilizing this project within your own, please feel free to do so, and let me know!

Use Cases:

  • UI for qbt_migrate
  • FastResume Class
  • Torrent Manager

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qbt_migrate-2.3.1.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qbt_migrate-2.3.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file qbt_migrate-2.3.1.tar.gz.

File metadata

  • Download URL: qbt_migrate-2.3.1.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for qbt_migrate-2.3.1.tar.gz
Algorithm Hash digest
SHA256 f7eba0495de7815017f1f8772d6b7cb1d790054a9cce0207f4dbad0e6c18cf96
MD5 3cdd41bc47cd29b5487f9e999c06a59b
BLAKE2b-256 48ef3552fb0baa106bb8fbd8d7b26454bff46bb771b3029f109fad271aa0fecb

See more details on using hashes here.

File details

Details for the file qbt_migrate-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: qbt_migrate-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for qbt_migrate-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f9f4ac48ca56c11572fb1e7179f073a7dcaecb3581346fdf7d105ca537fc8f2
MD5 ed2c1b6d3769003667c58cf02a127a7a
BLAKE2b-256 a1315c98d9425de9dfba18f6e6171948195a85fa04a2e78619af3631b24c228a

See more details on using hashes here.

Release history Release notifications | RSS feed

3.3.0

2 files

3.2.0

2 files

3.1.0

2 files

3.0.0

2 files

2.3.2

2 files

This release

2.3.1 This release

2 files

2.3.0

2 files

2.2.1

2 files

2.2.0

2 files

2.1.6

2 files

2.1.5

2 files

2.1.4

2 files

2.1.3

2 files

2.1.2

2 files

2.1.0

2 files

2.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page