A command-line tool for renaming media libraries to comply with Jellyfin's official naming conventions for both TV Shows and Movies.
- Interactive Mode Enhancements: Users can now edit detected metadata directly from interactive prompts by typing 'e' followed by the option number (e.g., 'e2' to edit the second option).
- Advanced TV Show Detection: Automatically detects episodes from a wide variety of filename and folder structures, including:
- Standard
SxxExxformat (Show.S01E01.mkv) episode xxformat (Show.episode 01.mkv)eXoreXXformat (Show.e01.mkv)- Three-Digit format (
Show.101.mkvfor Season 1, Episode 1) - Folder-based numbering (
.../Season 1/01.mkv,.../Season One/01.mkv,.../First Season/01.mkv) - Multi-Episode Files: Correctly parses and formats files containing multiple episodes from patterns like
S01E01-E02,101-102, and.../Season 1/01-02.mkv.
- Standard
- Intelligent TV Show Grouping:
- Scans and groups multiple directories belonging to the same show (e.g.,
Breaking Bad (2008)andBreaking Bad Season 2) into a single, streamlined renaming operation. - Performs case-insensitive grouping to correctly identify shows with inconsistent folder names.
- Prompts for confirmation before merging grouped shows to ensure accuracy.
- Scans and groups multiple directories belonging to the same show (e.g.,
- Smart Output Directory Logic: Prevents the creation of nested output folders. When you scan a directory containing just a single show (e.g.,
/downloads/The Mentalist Complete/), the renamedTV Showsfolder is created alongside it (in/downloads/), not inside it. - Comprehensive Subtitle Support: Automatically detects, matches, and renames a wide variety of subtitle files alongside their corresponding video files.
- Jellyfin Compliance: Renames files and creates proper folder structures following Jellyfin standards
- Dry Run Mode: Preview changes before applying them
- Enhanced Undo System: Complete undo capability with human-readable logs, proper error handling, and automatic cleanup
- Interactive Mode: Intelligent prompts showing detected metadata, file information, and prioritized naming options
- Cross-Platform: Works on Windows, Linux, and macOS
Download the latest executable for your platform (Windows, Linux, macOS) from the Releases page.
- Ensure you have Dart SDK installed
- Clone or download this repository
- Run
dart pub getto install dependencies - Build the executable:
dart compile exe bin/main.dart
To run renamer from any terminal window without specifying the full path:
- Move the downloaded/built
renamer.exeto a permanent location (e.g.,C:\Users\UserName\bin). - Open Start and search for "Environment Variables".
- Click Edit the system environment variables.
- Click Environment Variables.
- Under System variables (or User variables), find
Pathand click Edit. - Click New and paste the folder path from step 1.
- Click OK on all windows.
- Restart your terminal. You can now use
renameranywhere.
Move the binary to a directory already in your PATH, such as /usr/local/bin:
# Assuming you are in the directory with the binary
sudo mv renamer /usr/local/bin/Alternatively, add its custom location to your shell config (.bashrc, .zshrc, etc.):
export PATH="$PATH:/path/to/directory/containing/renamer"To test the tool, you can create a folder with sample media files (videos, subtitles) and run the commands against it.
# Basic functionality test
renamer scan --path /path/to/test_media
# or using short command
renamer s -p /path/to/test_media
# Dry run to see what happens without renaming
renamer rename --path /path/to/test_media --dry-run
#or using short command
renamer r -p /path/to/test_media --dry-runScan a directory to see what media files the tool detects.
renamer scan --path /path/to/your/media- Note that if you don't provide a path, the tool will scan the current directory.
Preview the renaming operations without making any changes. This is the default behavior.
renamer rename --path /path/to/your/mediaThe interactive mode will guide you through the process, showing detected episodes and providing naming options:
πΊ Found 2 episode files:
β’ T.M.101.rmvb β Season 1, Episode 1
β’ T.M.102.rmvb β Season 1, Episode 2
Detected show name options:
1. The Mentalist
2. T M 101
3. Enter different show name
4. Skip these files
Select option: 1
...
π Preview of final structure:
βββ TV Shows
βββ The Mentalist
βββ Season 01
βββ The Mentalist S01E01.rmvb
βββ The Mentalist S01E02.rmvb
This is a dry run. No files will be modified.
To apply the changes, run the rename command and confirm at the prompt, or use the --no-interactive flag.
# Run interactively and confirm at the prompt
renamer rename --path /path/to/your/media
# Or, run non-interactively (not recommended until you've done a dry run)
renamer rename --path /path/to/your/media --no-interactiveBy default, the tool moves (renames) files. You can change this behavior using the --mode (-m) option. This is particularly useful if you want to seed your media from the original location while having a clean structure for Jellyfin.
Available Modes:
move(Default): Renames the files.hardlink: Creates a hard link. Best for seeding; takes up no extra space. (Target and source must be on the same drive).symlink: Creates a symbolic link (shortcut) - this requires admin permissions on Windows.copy: Copies the files. (Uses double the storage space).
# Create hard links
renamer rename --path /path/to/downloads --mode hardlink
# Create symbolic links
renamer rename -p /path/to/downloads -m symlinkNote
The undo log (rename_log.json) is only generated when using the default move mode. Copy, hardlink, and symlink operations do not generate an undo log. Also, empty source directories are not deleted in these modes.
For processing a specific show or movie folder without scanning the entire library structure (useful for downloads folders or specific cleanup).
renamer rename-single --path "/path/to/downloads/My Show Season 1"This acts exactly like strict mode:
- Errors if multiple movies or mixed content is found.
- Creates the log file inside the target folder (or its parent), keeping logs localized.
If you need to revert the last operation, use the undo command.
renamer undoTo enable detailed debug logging for troubleshooting, use the global --verbose (-v) flag:
renamer rename --path /path/to/your/media --verboseMovies are organized as:
/Movies/
βββ Movie Name (Year)/
βββ Movie Name (Year).mkv
βββ Movie Name (Year).default.srt
Example:
/Movies/
βββ Inception (2010)/
βββ Inception (2010).mkv
βββ Inception (2010).default.srt
TV shows are organized as:
/TV Shows/
βββ Show Name (Year)/
βββ Season 01/
βββ Show Name (Year) S01E01 Episode Title.mkv
βββ Show Name (Year) S01E01.default.srt
Example:
/TV Shows/
βββ Breaking Bad (2008)/
βββ Season 01/
βββ Breaking Bad (2008) S01E01 Pilot.mkv
βββ Breaking Bad (2008) S01E01.default.srt
-v, --verbose: Enable detailed debug logging for troubleshooting.-h, --help: Show help information
-p, --path: Root directory to scan (required)
-p, --path: Root directory to process (required)-d, --dry-run: Preview changes without applying them-i, --interactive: Prompt for confirmation (default: true)-l, --log: Path to undo log file (default: rename_log.json)-o, --output: Specific output directory for renamed files. If not specified, uses strict mode logic or scans root.-m, --mode: Rename mode (move, copy, hardlink, symlink)
-p, --path: Path to the show or movie folder (required)-d, --dry-run: Preview changes without applying them-i, --interactive: Prompt for confirmation (default: true)-l, --log: Path to undo log file (default: rename_log.json)
-l, --log: Path to undo log file (default: rename_log.json)-p, --preview: Show what will be undone without applying
The tool automatically detects media types based on filename patterns:
- TV Shows: Files containing
S01E01,S02E05,episode xxformat,eX/eXXformat, three-digit formats like101(S01E01), multi-episode formats likeS01E01-E02or101-102, numbered files within season folders, and word-based season names (e.g., "Season One", "First Season"). - Movies: Files containing years (e.g.,
2010,2023) - Subtitles: Files with extensions
.srt,.sub,.ass,.ssa,.vtt - Unknown: Files that don't match these patterns
Subtitle files are automatically associated with video files using intelligent matching:
- Exact match:
Movie.mkvβMovie.srt - Episode code match:
Show.S01E01.mkvβS01E01.srt - Close name match:
Movie.mkvβMovie.English.srt - Directory-based: Subtitles in the same folder as videos are associated
- Stricter Numeric Matching: Prevents incorrect associations between purely numeric filenames (e.g.,
10.mkvwill not be matched with1.srt).
The tool now supports Arabic language patterns for detecting season and episode information:
- Seasons: Recognizes Arabic words for seasons, including numeric (e.g.,
Ψ§ΩΩ ΩΨ³Ω 1,Ψ§ΩΩ ΩΨ³Ω ΩΨ§ΨΨ―) and ordinal forms (e.g.,Ψ§ΩΩ ΩΨ³Ω Ψ§ΩΨ£ΩΩ,Ψ§ΩΩ ΩΨ³Ω Ψ§ΩΨ«Ψ§ΩΩ) up to the twentieth season. - Episodes: Recognizes the Arabic word for episode (
Ψ§ΩΨΩΩΨ©) followed by the episode number (e.g.,Ψ§ΩΨΩΩΨ© 1).
All rename operations (including subtitles) are logged to rename_log.json with timestamps. The undo command reads this log and reverses all operations in reverse chronological order.
- Human-readable logs: The log file includes both human-readable operation summaries and machine-readable JSON
- Smart error handling: Only deletes the log file after complete success; preserves logs for partial failures
- Automatic cleanup: Removes empty directories created during renaming
- Progress tracking: Shows detailed progress during undo operations
Important: Always run in dry-run mode first to verify changes before applying them.
-
Scan your media directory:
renamer scan --path ./media
-
Preview changes:
renamer rename --path ./media --dry-run
-
Apply changes:
renamer rename --path ./media
-
If something goes wrong, undo:
renamer undo
Process a large library non-interactively:
renamer rename --path /mnt/media --no-interactive --log /var/log/renamer.jsonVerbose output for debugging:
renamer rename --path ./test --dry-run --verbose- Dry-run mode prevents accidental changes
- Undo logging tracks all operations (videos and subtitles) for reversal
- File validation ensures paths exist before processing
- Error handling gracefully handles permission issues and missing files
- Smart cleanup removes empty directories after undo operations
- Cross-platform paths work correctly on Windows, Linux, and macOS
# Unit tests
dart test
# Integration testing
# Create a folder with sample content to test manually
renamer scan --path /path/to/sample_content
renamer rename --path /path/to/sample_content --dry-rundart compile exe bin/main.dartdart analyze
dart format .This project is open source. See the license file for details.
