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.2.tar.gz (6.0 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.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: subtitle_renamer-0.1.2.tar.gz
  • Upload date:
  • Size: 6.0 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.2.tar.gz
Algorithm Hash digest
SHA256 3a30bedb626e0e8de96635fc6bb80d70c96d86aa07ca55d56bc45a92e29253da
MD5 f854f5386b8b6693e01374fb7f96e8f8
BLAKE2b-256 d029ad7a7e992ebea81c58fde1c3d22f0fa437980c067268c9b766f19db894a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: subtitle_renamer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 952ab90947d2dcc4050c7264e8af8331468d1ab136c51de60287815b8b298be4
MD5 dd7666b6c62f8c964d5d2f80ec79bc41
BLAKE2b-256 31098ef7db590338f81d82bb86ac280031a85f1414c58713b82b1cc4ac122977

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