Skip to main content

A utility to rename subtitle files to match video files based on episode numbers

Project description

Subtitle Renamer

A utility to rename subtitle files to match video files based on episode numbers.

Overview

Subtitle Renamer automatically detects video files and their corresponding subtitle files based on episode numbers or similar patterns, and renames the subtitle files to match the video files while preserving their extensions.

This is particularly useful for TV shows, anime, or any video content with episodes where you want the subtitle filenames to match the video filenames.

Installation

Install from PyPI:

pip install subtitle-renamer

Usage

Command Line

subtitle-renamer [options]

Options

  • -v, --video-dir: Directory containing video files (defaults to current directory)
  • -s, --subtitle-dir: Directory containing subtitle files (defaults to video directory)
  • -r, --recursive: Search recursively in directories
  • -d, --dry-run: Show what would be done without actually renaming files
  • --remove-originals: Remove original subtitle files after renaming
  • --keep-existing: Skip renaming if target file already exists
  • --verbose: Show detailed logs
  • --video-pattern: Custom regex pattern to extract episode numbers from video files (can be specified multiple times)
  • --subtitle-pattern: Custom regex pattern to extract episode numbers from subtitle files (can be specified multiple times)

Examples

Basic usage (current directory):

subtitle-renamer

Specify video and subtitle directories:

subtitle-renamer --video-dir /path/to/videos --subtitle-dir /path/to/subtitles

Preview changes without renaming:

subtitle-renamer --dry-run

Recursive search through subdirectories:

subtitle-renamer --recursive

Python API

You can also use Subtitle Renamer as a library in your Python code:

from subtitle_renamer import SubtitleRenamer

renamer = SubtitleRenamer(
    video_dir="/path/to/videos",
    subtitle_dir="/path/to/subtitles",
    dry_run=True,
    recursive=True
)

renamed_count, total_count = renamer.run()
print(f"Renamed {renamed_count} of {total_count} subtitle files")

How It Works

  1. The tool scans for video files and subtitle files in the specified directories
  2. It extracts episode numbers using regex patterns
  3. It matches video and subtitle files with the same episode number
  4. It renames the subtitle files to match the video files, keeping their original extension

Supported Formats

  • Video: .mkv, .mp4, .avi, .mov, .flv, .wmv, .m4v, .webm
  • Subtitles: .srt, .ass, .ssa, .vtt, .sub

License

MIT

Project details


Download files

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

Source Distribution

subtitle_renamer-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

subtitle_renamer-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file subtitle_renamer-0.1.1.tar.gz.

File metadata

  • Download URL: subtitle_renamer-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.16 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for subtitle_renamer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bd8c00ea55e16b96349b87c9ff5eadf84e5fb060ff420f07c63a2440a75f7bcb
MD5 cde8114a0703e5bb1066246e5da0e629
BLAKE2b-256 3353698239e28c6adfe842d7c61b3af9b41038501c0e332f08133204312e6959

See more details on using hashes here.

File details

Details for the file subtitle_renamer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: subtitle_renamer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.10.16 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for subtitle_renamer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36bd48c5a3bace569b05bf97431dc611b3d31962e4c4ea092353f98ef1402d32
MD5 b3d301c14a5fada9e1e17c81b113cdca
BLAKE2b-256 a252e3c316564170b79ae3aae584bfd3849f2091b482d3a2e2b66d67d1cd4ffe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page