# rename-subtitles A GNOME/Nautilus script that renames subtitle files so they match their video files, letting players (GNOME Videos, VLC) auto-load them. ## What it does - Pairs subtitles to videos **by episode number** (`S01E02`, `1x02`, `Season 1 Episode 2`, or a lone `E02`). - Falls back to **1-to-1** matching when a folder has a single video and a single subtitle with no episode markers. - **Handles still-downloading videos**: a `Show.S01E02.mkv.part` is matched as if already complete, so the subtitle is named for the finished file (`Show.S01E02.srt`, not `Show.S01E02.mkv.srt`). - **Preserves language codes**: `sub.en.srt` matched to `Movie.mkv` → `Movie.en.srt`. - **Never overwrites** an existing file — such cases are reported as skipped. - Shows a **Zenity confirmation dialog** listing every planned rename before touching anything. Video extensions: mkv mp4 avi m4v mov wmv flv webm mpg mpeg ts m2ts Subtitle extensions: srt sub ssa ass vtt idx sup ## Install (Nautilus right-click) ```sh cp rename-subtitles ~/.local/share/nautilus/scripts/"Rename subtitles to match videos" chmod +x ~/.local/share/nautilus/scripts/"Rename subtitles to match videos" nautilus -q # reload the Scripts menu (quits open Files windows) ``` Then in **Files**: select the folder (or the video + subtitle files), right-click → **Scripts → Rename subtitles to match videos**. ### Dependency The confirmation dialog needs **zenity**: ```sh sudo dnf install zenity # Fedora ``` Without zenity the script still works from a terminal (it prompts on the console), but the right-click dialog will not appear. ## Command-line usage ```sh ./rename-subtitles [PATH ...] # files and/or folders; defaults to cwd ```