No description
Find a file
2026-09-04 13:39:16 +02:00
dvd2h265.sh Removing Apple ._ files 2026-07-27 07:11:46 +00:00
list_audio.sh Initial version 2026-08-24 08:52:02 +00:00
list_runtimes.sh Initial version 2026-08-24 08:52:02 +00:00
movie_rename.sh Initial version 2026-09-04 13:31:47 +02:00
README.md Update README.md 2026-07-24 13:13:23 +02:00
resize_1080p_hvec.sh Initial version 2026-09-04 13:31:47 +02:00
set_default_audiotrack.sh Fixes 2026-08-24 11:02:40 +02:00
simple_movie_rename.sh Fixed 2026-09-04 13:39:16 +02:00
srtsyncfix.sh Fixes 2026-07-24 12:35:04 +00:00

srtsyncfix.sh

srtsyncfix.sh is a small Bash utility that automatically synchronizes .srt subtitle files with their corresponding .mkv video files using ffsubsync. It scans a directory (or a single MKV file), finds matching SRTs, fixes their timing, and prevents repeated processing by adding a marker line to alreadysynced subtitles.

The script is designed for media libraries where filenames may contain spaces, parentheses, brackets, or other special characters.


Features

  • Automatically finds .mkv files in a directory
  • Matches .srt files based on the MKV basename
  • Uses ffsubsync to correct subtitle timing
  • Adds a marker line to avoid reprocessing alreadysynced subtitles
  • Safely handles filenames with spaces, brackets, parentheses, and unicode
  • Removes macOS AppleDouble junk files (._*)
  • Optional language filtering (e.g., eng, nld, pob)

Requirements

1. ffsubsync

This is the core subtitlesync engine.

Install via pip:

pip install ffsubsync

Or, if using Python 3 explicitly:

pip3 install ffsubsync

2. Python 3

Required by ffsubsync.

Check:

python3 --version

3. Bash

The script uses Bash arrays, process substitution, and set -euo pipefail.

4. Standard Unix tools

These are available on all Linux distributions:

  • find
  • mv
  • grep
  • dirname
  • basename
  • printf
  • mapfile

No additional packages required.


Usage

Process the current directory

./srtsyncfix.sh .

Process a specific movie file

./srtsyncfix.sh "FERRARI (2023) - [1080p].mkv"

Process only a specific subtitle language

./srtsyncfix.sh . nld

This will only sync subtitles ending in .nld.srt.


How it works

  1. Removes AppleDouble files (._*)
  2. Optionally strips leading/trailing quotes from filenames
  3. Detects MKV files
  4. For each MKV:
    • Finds matching SRT files
    • Skips SRTs already containing the marker line
    • Runs ffsubsync to generate a corrected subtitle
    • Backs up the original SRT
    • Replaces it with the fixed version
    • Appends a marker line:
      Fixed by ffs on YYYY-MM-DD HH:MM
      

Backup behavior

Every processed subtitle is backed up automatically:

original.srt → original.srt.bck

This ensures you can always revert if needed.


Notes

  • The script does not modify MKV files.
  • The script only processes .srt subtitles.
  • The skipmarker prevents expensive reprocessing.
  • Filenames with quotes can be cleaned automatically if desired.

If you want, I can also generate:

  • a manpage style README
  • a GitHubready README with badges
  • a usage example section with real MKV/SRT filenames

Just tell me what style you prefer.