- Plex Organizer
- Features
- Requirements
- Installation
- Update
- Configuration
- Usage
- Dev Container (VS Code)
- Contributing
- License
- Issues and Feature Requests
Plex Organizer is a Python-based utility designed to help manage and organize media files for Plex Media Server. It automates tasks such as renaming files, deleting unwanted files, moving directories, and cleaning up empty folders.
NB!! Any data loss is not on me but you can still report any bugs or faults you find in issues
- Torrent Removal: Removes torrents from the client after processing.
- File Renaming: Automatically renames media files based on predefined rules for TV shows and movies.
- Unwanted File Deletion: Removes unnecessary files/folders from specified directories.
- Directory Management: Moves directories to their appropriate locations and deletes empty directories.
- Customizable Directories: Supports separate directories for TV shows and movies.
- Handle Plex: Handles plex directories and optimized versions.
- Audio language tagging (optional): If enabled, detects missing audio track languages and writes ISO 639-2 tags into the container metadata (uses
ffprobe/ffmpeg+faster-whisper). - Subtitle embedding (optional): If enabled, embeds external subtitles into the video file and tags subtitle language/type metadata (uses
ffprobe/ffmpeg+langdetect). - Config file: Ini file for common configuration options that can be set, disabled or enabled (beware, some settings might not do anything if already run and info removed from file names, for example turning off quality inclusion and then enabling it)
Notes:
- Cleanup is intentionally aggressive: only video files (
.mkv,.mp4), in-progress qBittorrent files (.!qB), and the organizer index file (.plex_organizer.index) are kept. Subtitle files/folders (e.g.Subs/,Subtitles/) are removed. - The organizer keeps a per-library index (
.plex_organizer.index) so already-processed files can be skipped on future runs. - If qBittorrent torrent removal is enabled (by providing a torrent hash), the qBittorrent Web API must be reachable and credentials must be set.
start_directory/
├── movies/
│ ├── Venom.2018.BluRay.x264-[YTS.AM].mp4
│ ├── Warcraft.2016.1080p.BluRay.x264-[YTS.AG].mkv
│ ├── 1917 (2019) [1080p] [BluRay] [5.1] [YTS.MX]/
│ │ └── Subs/
│ │ ├── English.srt
│ │ └── Spanish.srt
│ ├── 2 Fast 2 Furious (2003) [1080p]/
│ │ └── Subs/
│ │ └── French.srt
│ ├── 6 Underground (2019) [WEBRip] [1080p] [YTS.LT]/
│ │ ├── 6 Underground (2019).mp4
│ │ └── Subs/
│ │ ├── Turkish.tur.srt
│ │ ├── Norwegian.nor.srt
│ │ └── Danish.dan.srt
│ └── random_file.txt
└── tv/
├── Black Bird/
│ ├── S01E01.mp4
│ ├── S01E02.mp4
│ └── unwanted_file.txt
├── Colony/
│ ├── S01E01.mp4
│ ├── S01E02.mp4
│ └── extra_file.txt
└── Loki/
├── S01E01.mp4
└── S01E02.mp4
start_directory/
├─ movies/
│ ├── 1917 (2019) 1080p.mp4
│ ├── 2 Fast 2 Furious (2003) 1080p.mp4
│ ├── 6 Underground (2019) 1080p.mp4
│ ├── Venom (2018).mp4
│ └── Warcraft (2016) 1080p.mkv
└─ tv/
├── Black Bird/
│ └─ Season 1/
│ ├── Black Bird S01E01.mp4
│ └── Black Bird S01E02.mp4
├── Colony/
│ └─ Season 1/
│ ├── Colony S01E01.mp4
│ └── Colony S01E02.mp4
└── Loki/
└── Season 1/
├── Loki S01E01.mp4
└── Loki S01E02.mp4
- Python 3.x
- Dependencies listed in
requirements.txt ffmpeg/ffprobeon PATH (required ifenable_audio_tagging = trueand/orenable_subtitle_embedding = true)
-
Clone the repository:
git clone https://github.com/Toomas633/Plex-Organizer.git cd Plex-Organizer -
Install dependencies (recommended):
bash ./install.shOr, to upgrade already-installed dependencies:
bash ./install.sh --upgradeTo update to the latest version just run update.sh (it will also run install.sh afterwards).
./update.shAll user configuration is handled in config.ini.
The file is auto-managed on startup:
- Missing required sections/options are added.
- Unknown options inside known sections are removed.
Key sections:
[qBittorrent]host: Base URL for the Web API (defaulthttp://localhost:8081). Used for torrent removal.username: Username for qbittorrent web apipassword: Password to authenticate with
[Settings]delete_duplicates: Iftrue, deletes source files when the destination already exists.include_quality: Iftrue, appends quality like1080pto renamed files.capitalize: Iftrue, title-cases show/movie names.cpu_threads: Limits CPU parallelism for some processing steps.
[Logging]enable_logging: Iftrue, logs errors to a log filelog_file: Name of the log fileclear_log: Iftrue, log file is cleared on each run of the scripttimestamped_log_files: Iftrue, log files are timestamped and put to logs folderlevel: EitherINFOby default orDEBUGif Debug log rows are needed
[Audio]enable_audio_tagging: Iftrue, runs audio language tagging after moves.whisper_model_size: Whisper model size forfaster-whisper(defaulttiny).
[Subtitles]enable_subtitle_embedding: Iftrue, embeds external subtitles and tags metadata before subtitle files/folders are removed.
NB!! Make sure the qBittorrent host is correct. Torrent removal is best-effort: failures are logged and processing continues.
Start directory should have either...
- The folders for movies and tv as shown in the example. Show names are taken from the parent folder inside tv folder and only episode, season and quality are taken from the file names.
- Just the given torrent save path folder (%D option in qBittorrent)
To run manually just go to the Plex-Organizer cloned or downloaded folder and run:
./run.sh <start_directory>Add this command to qBittorrent options under "Run external program on torrent finished":
/bin/bash <path_to_script>/run.sh <start_directory> <torrent_hash>Arguments:
<start_directory>: The base directory containing the tv and movies subdirectories or %D in qBittorrent ui.<torrent_hash>: Optional: The hash of the torrent to be removed (omit for testing purposes or to ignore torrent automatic removal). Argument %I in qBittorrent ui.
Be sure to put arguments between "%D" to avoid whitespace cuttofs
Example:
For performance reasons it is recommended that %D is used instead of entire directory like /mnt/share. This way only the specific folder will be organized not entire library on each call. Putting your root directory like /mnt/share will remove the torrent with the given hash and process the directories /mnt/media/tv and /mnt/media/movies.
This repo includes a VS Code Dev Container configuration.
- Install Docker (Docker Desktop) and VS Code.
- In VS Code:
Dev Containers: Reopen in Container.
The container includes ffmpeg (for faster-whisper) and will create/initialize venv/ + install requirements.txt on first create.
It does not auto-run test.sh.
For the same quick verification flow as test.bat (but for Linux/Dev Container), run:
bash ./test.shContributions are welcome! Please follow these steps:
Fork the repository. Create a new branch for your feature or bug fix.Commit your changes and push the branch. Open a pull request.
This project is licensed under the GNU General Public License v3.0.
If you encounter any issues or have feature requests, please use the GitHub Issues page.
Happy organizing!
