Skip to content

Latest commit

 

History

History
249 lines (161 loc) · 12 KB

README.en.md

File metadata and controls

249 lines (161 loc) · 12 KB

SubRenamer

🎞 One-click batch subtitle renaming tool

A Tool for Batch Rename Subtitle Files to Match Video Names with One Click.

Why? If the video and subtitle filenames match, any video player can automatically load the subtitles.

Goal? Rename external subtitle files to match the video filenames.

What sets SubRenamer apart from regular batch renaming software?

SubRenamer specializes in renaming subtitle files and is straightforward to use.

For most video and subtitle files, simply drag them into the program for automatic and precise recognition, allowing one-click renaming without the complex settings of typical renaming software.

How to get SubRenamer?

Click the links below to download the latest version:

Windows (x86) macOS (M1) Linux (x86)

You can find historical versions and changelogs on the Release page.

Features

  • Automatic Matching: One-click matching with automatic recognition algorithms.
  • Drag & Drop Import: Quickly import files and folders via drag and drop.
  • Multi-language Matching: Supports multi-language subtitle matching (one-to-many mapping).
  • Language Filtering: Automatically detects and filters subtitles of specified languages before import.
  • Multiple Matching Rules: Supports manual matching for complex filename formats.
  • Manual Matching Editor: Customizable rules with simple wildcards.
  • Regex Editor: Includes a regex matching test tool.
  • Match Fine-tuning: Allows fine-tuning of matching results.
  • Rename Commands: Quickly copy Linux rename commands to clipboard via right-click.
  • Subtitle Backup: Automatically backs up subtitle files before renaming.
  • Append Suffix: Supports adding custom suffixes before file extensions.
  • File Recognition: Automatically distinguishes between video and subtitle files by extension, with customization support.
  • Shortcuts: Supports keyboard shortcuts for efficiency.
  • Dark Mode: Follows system settings for dark mode.
  • Always on Top: Keeps the window on top for easy operation.
  • I18n: Supports multiple languages, including Chinese and English.
  • Cross-platform: Supports Windows, macOS, and Linux.
  • Small Size: Around 15MB.

Important

Rewrite Note: The first version of SubRenamer was released in 2019, developed with WinForm and only supported Windows. In 2024, SubRenamer was rewritten and released as v2.0, using AvaloniaUI + .NET 8, now supporting cross-platform functionality on Windows, macOS, and Linux (not using Electron.js).

Match Editor Custom Matching Rules
Manual Matching Rule Editor Regex Rule Editor
Dark Mode Subtitle Language Filtering
Right-click Menu Shortcut Support Settings Interface

Drag & Drop Import

2024-04-13.14.56.44.webm

Renaming Instructions

If the video and subtitle files are in different folders, the renaming process will copy the subtitle files to the video folder without altering the original subtitle files, so no backup is needed.

Conversely, if the video and subtitle files are in the same folder, the renaming process will directly modify the subtitle filenames (you can enable backup in settings to save the original subtitle files in the SubBackup directory).

The renamed subtitle filenames will match the video filenames.

Algorithm Principle

Automatic Matching Mode

The automatic matching mode determines the episode (extract) by comparing the differences (diff) between filenames and automatically associates video and subtitle files (mapping) to achieve automatic matching.

To perform automatic matching, you need to import at least two video files and two subtitle files with consistent naming formats.

Manual Matching Mode

The automatic matching mode may fail with complex filename formats, in which case you can switch to manual matching mode. Manual mode allows you to define rules (supporting simple wildcards and regular expressions). The program provides a simple editor for quickly writing matching rules.

FAQ

macOS can't open, says it's damaged

There are many solutions online. Here's one method: open the terminal and enter the following command:

sudo xattr -d com.apple.quarantine /Applications/SubRenamer.app

The reason is it isn't signed by an Apple developer, which requires a $99/year developer account.

No scaling on Linux Wayland desktop environment?

This is an upstream issue. AvaloniaUI may not scale correctly on Wayland, resulting in small text. You can set the environment variable to manually set the scaling factor at startup.

AVALONIA_SCREEN_SCALE_FACTORS="eDP-1=2;" ./SubRenamer

Multi-Language Translation (I18n)

SubRenamer supports multiple languages. Currently available languages include:

  • English
  • 简体中文 (Simplified Chinese)
  • 繁體中文 (Traditional Chinese)
  • 日本語 (Japanese)

Language files are located in the SubRenamer/Assets/Lang directory. You can add or improve translations by editing the XAML files. Contributions are welcome, feel free to submit a PR to add more language translations.

Found a BUG?

Report it on the issues page.

Stargazers over time

Stargazers over time

Compilation Instructions

It is recommended to use JetBrains Rider or Visual Studio 2022 to open the project.

Prerequisites

Windows

  • Visual Studio 2022, including .NET 8 & Desktop development with C++ workload.
  • Alternatively, you can install JetBrains Rider to build the project. (Recommended).

Fedora (36+)

sudo dnf group install "C Development Tools and Libraries" "Development Tools"

sudo dnf install dotnet-sdk-8.0 libicu-devel cmake zlib-devel -y

Ubuntu (20.04+)

sudo apt-get install dotnet-sdk-8.0 libicu-dev cmake zlib1g-dev -y

macOS (12+)

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install xcode command line tools
xcode-select --install

# Install dependencies
brew install dotnet-sdk8 icu4c cmake zlib

Unit Testing

dotnet test SubRenamer.Tests --verbosity normal

Unit test code is in the SubRenamer.Tests directory. It is recommended to use Rider's built-in visual tool to run tests and view results.

Test Data

The TopLevelTests.json file contains test case data, including various subtitle and video filename lists for testing the matching algorithm. Feel free to submit a PR to add more test cases. After modifying the file, run the unit test command to view the results.

Each code submission will trigger unit tests via GitHub Actions to ensure code quality.

Building a Single File

On Windows, to build a single exe file with statically linked dependencies (without additional dynamic link DLL dependencies), download these DLL files and place them in the native directory. Then add the environment variable ENABLE_NATIVE_LIBS=true before compiling.

Publish with NativeAOT

dotnet publish -r <RID> -c Release

# Build for Windows example
dotnet publish -r win-x64 -c Release

Build the installer with NSIS

NSIS installer ~13MB size

pwsh ./publish.ps1

If you build the installer with NSIS, you can ignore UPX compression for better startup performance.

Technical Implementation

  • AOT compilation, single file publishing
  • Multi-platform packaging and distribution
  • Cross-platform adaptation handling
  • IoC container, dependency injection, MVVM, LINQ
  • JSON source generator
  • Multithreading, coroutines
  • Global exception handling
  • Error log reporting
  • JSON configuration management
  • Version management, update checking
  • Usage statistics
  • GitHub API
  • GitHub Actions CI/CD
  • Unit testing
  • Multi-language, internationalization
  • HiDPI support

License

This project is open-sourced under the GPL-2.0 license. See the LICENSE file for details.