Skip to content

hmsmart/subadd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Readme

This script was generated by Gemini with the goal of simplifying the process of renaming external language subtitle files (.ass or .srt) to match the naming convention for Jellyfin's External File for subtitles. This script is extremely limited in its current state, and may be changed or modified as needed to suit other use cases.

File Matching Logic

The script works by checking the episode number (E##) extracted from the video filename and searching the source directory for a subtitle file containing that same number (##) in one of these three common formats:

Format Check Example Subtitle Filename Resulting Match Pattern
Loose Space Title 01 Source.ass * 01*
Square Brackets [Title] [02][Source].ass *[02]*
Curly Braces Title {03} Source.srt *{03}*

Prerequisites

Bash shell environment (Linux, macOS, WSL).

The video files (currently .mkv) must follow a consistent episode naming pattern that includes the season and episode number, such as: ...S01E01...

Usage

To run the script, execute it from your terminal, providing three mandatory arguments:

  1. The Source Directory containing the raw, unnamed subtitle files.

  2. The Destination Directory containing the video files whose names the subtitles should match.

  3. The Language ISO Code (e.g., jpn, eng, fre).

./subadd.sh [-c|--copy] [-r] <SUBTITLE_SOURCE_DIR> <VIDEO_DESTINATION_DIR> <LANG_ISO_CODE>

Options

Option Description
-c, --copy Copy subtitles to destination instead of moving
-r Rename original subtitle in source folder to match destination naming
-cr, -rc Combine copy and rename original (both actions)
-h, --help Show help message

Example

Suppose you have:

Subtitles in: ./Food Court de, Mata Ashita/

Videos in: /mnt/media/Anime/See You Tomorrow at the Food Court (2025)/Season 01/

To match the Japanese subtitles to the videos in the destination directory:

./subadd.sh "Food Court de, Mata Ashita" "/mnt/media/Anime/See You Tomorrow at the Food Court (2025)/Season 01/" "jpn"

Copy and Rename Example

To copy subtitles to destination and also rename the original files in the source folder:

./subadd.sh -cr "Subin" "DstDir" "ja"

Input:

Subin/[Nekomoe kissaten] Apocalypse Hotel - 12 [WebRip][JPN].ass

Output:

Subin/Apocalypse Hotel (2025) - S01E12 - 012 - Title [Bluray-1080p Remux][8bit][h264][FLAC 2.0][JA]-LaCroiX.ja.ass
DstDir/Apocalypse Hotel (2025) - S01E12 - 012 - Title [Bluray-1080p Remux][8bit][h264][FLAC 2.0][JA]-LaCroiX.ja.ass

Output

A successful run will move and rename the subtitle file to match the video, appending the ISO code:

Original Video Name Matched Subtitle Name Final Subtitle Name
...S01E01...mkv Food Court... 01.ass ...S01E01...mkv.jpn.ass
...S01E02...mkv [MingY]...[02].ass ...S01E02...mkv.jpn.ass

If a match is not found for an episode, a warning will be displayed.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages