A Python script that scans .mkv files and removes non-English subtitle tracks, keeping your media library clean and consistent.
It uses mkvmerge to safely rewrite files while preserving only allowed subtitle languages.
-
Recursively scans one or more directories for
.mkvfiles -
Detects subtitle tracks using
mkvmerge -
Removes subtitles that are not in allowed languages (default: English)
-
Tracks previously processed files to avoid unnecessary reprocessing
-
Logs:
- Processed files
- Missing files
- Files flagged during dry runs
-
Supports a dry-run mode to preview changes without modifying files
-
Displays progress using
tqdmprogress bars
Make sure the following are installed:
Python 3.7+ recommended
Provides mkvmerge, which is required.
Install via package manager:
# Ubuntu/Debian
sudo apt install mkvtoolnix
# Arch / Artix
sudo pacman -S mkvtoolnix-cliInstall required Python packages:
pip install tqdmpython script.pypython script.py --force-recheckYou can configure behavior via environment variables or directly in the script.
INPUT_DIRECTORIES = os.getenv(
"MKV_INPUT_DIRS",
"/home/Movies/,/home/Movies2/,/home//Movies3/"
).split(",")LOG_DIRECTORY = os.getenv(
"MKV_LOG_DIR",
"/home/Program/scripts/Delete_subs/"
)Stores:
non_english_subs.logchecked_files.logmissing_files.logDRYRUN-Flagged.log
ALLOWED_SUB_LANGUAGES = ["eng", "en", "und"]- Uses ISO language codes
Default keeps:
eng→ Englishen→ English (alternative code)und→ Undefined (often safe to keep)
Modify to suit your needs:
ALLOWED_SUB_LANGUAGES = ["eng", "jpn"]DRY_RUN = False- Set to
Trueto simulate changes only - No files will be modified
- Flagged files will be logged instead