Torrent Mover v8.0

Description

Torrent Mover is a Bash script designed to automate the processing of completed torrents in Transmission. It moves or copies downloaded files from a Transmission‑reported download location to designated destination directories on your system. This enhanced version includes robust locking, advanced error handling, parallel processing, configurable path mapping, improved archive extraction, and optional file integrity verification.

Features

Requirements

Installation

  1. Download the Script: Save the script (e.g., torrent-mover.sh) to your desired location (e.g., /usr/local/bin/).
  2. Make It Executable:
    chmod +x /usr/local/bin/torrent-mover.sh
  3. Create/Edit the Configuration File: The script expects a configuration file at /etc/torrent/mover.conf. See the configuration section below.

Configuration

Edit or create /etc/torrent/mover.conf with the following content:

# Transmission settings
TRANSMISSION_IP="192.168.1.100"         # Replace with your Transmission server's IP
TRANSMISSION_PORT="9091"                # Replace with your Transmission server's port
TRANSMISSION_USER="your_username"       # Transmission username (if set)
TRANSMISSION_PASSWORD="your_password"   # Transmission password (if set)

# Path mapping settings
TRANSMISSION_PATH_PREFIX="/downloads"
LOCAL_PATH_PREFIX="/mnt/dsnas2"

# Destination directories
DIR_GAMES_DST="/mnt/dsnas1/Games"
DIR_APPS_DST="/mnt/dsnas1/Apps"
DIR_MOVIES_DST="/mnt/dsnas1/Movies"
DIR_BOOKS_DST="/mnt/dsnas1/Books"
DEFAULT_DST="/mnt/dsnas1/Other"

# Additional storage directories (comma-separated list)
STORAGE_DIRS="/mnt/dsnas/Movies"

# Performance settings
PARALLEL_THREADS="32"
PARALLEL_PROCESSING=1

# Operation mode: "move" or "copy"
COPY_MODE="copy"

# File tracking & integrity
PROCESSED_LOG="/var/log/torrent_processed.log"
CHECKSUM_DB="/var/lib/torrent/checksums.db"

# Logging settings
LOG_FILE="/var/log/torrent_mover.log"
LOG_LEVEL="INFO"          # Set to "DEBUG" for more verbose logging
USE_SYSLOG="false"        # Set to "true" to log messages to syslog

# Optional integrity verification after transfer ("true" to enable)
CHECK_TRANSFER_INTEGRITY="true"
    

Usage

Run the script using the following options:

You can combine options as needed. For example:

/usr/local/bin/torrent-mover.sh --dry-run --debug

How It Works

  1. Locking: Uses flock to ensure only one instance runs at a time.
  2. Path Translation: The script translates the Transmission-reported path (e.g., /downloads) to the local file system path (e.g., /mnt/dsnas2) using the configured mapping.
  3. Torrent Processing: Retrieves torrent info via transmission-remote and processes torrents that are 100% complete. It skips torrents already processed or those with duplicate source directories.
  4. File Verification & Deduplication: Compares file checksums between source and destination, and avoids re‑processing if a match is found.
  5. Archive Extraction: Extracts archives (RAR, ZIP, 7z) into subdirectories within the destination while preserving directory structure. The original archive is retained in the source until seeding criteria are met.
  6. Seeding Criteria: Checks seeding ratio and time. When thresholds are met, the torrent is removed from Transmission.
  7. Integrity Check (Optional): Optionally verifies file integrity by comparing MD5 checksums post-transfer.

Future Improvements

License

This script is provided as-is without any warranty. Use it at your own risk. Contributions and improvements are welcome.