A Python tool for generating .plexmatch files for Plex Media Server to help correctly match video files with complex filenames.
- Automatically scan video files in specified directory
- Support multiple video formats (mp4, mkv, avi, mov, etc.)
- Extract episode numbers from filenames
- Generate Plex-compatible
.plexmatchfiles - Support ordered matching mode
- Support custom season number setting
No external dependencies required. Uses Python standard library only.
python -m Plexmatch -d "C:\your\video\directory"python -m Plexmatch -d "//Network\directory"-d, --directory: Specify video file directory (required)-o, --order: Select only ordered files-s, --season: Specify season number
# Basic scan
python -m Plexmatch -d "C:\TV Shows\My Series\Season 1"
# Ordered matching with custom season
python -m Plexmatch -d "C:\TV Shows\My Series\Season 2" -o -s 23g2, 3gp, asf, asx, avc, avi, avs, bivx, bup, divx, dv, dvr-ms, evo, fli, flv, m2t, m2ts, m2v, m4v, mkv, mov, mp4, mpeg, mpg, mts, nsv, nuv, ogm, ogv, tp, pva, qt, rm, rmvb, sdp, svq3, strm, ts, ty, vdr, viv, vob, vp3, wmv, wtv, xsp, xvid, webm
- Scan all video files in the specified directory
- Filter out special files (like [SP], [MENU], etc.)
- Sort files using natural sorting
- Detect common filename prefix and intelligently remove trailing digits to avoid partial episode number extraction
- Extract episode numbers from filenames (supports 2+ digit episode numbers)
- Generate .plexmatch file with format
ep: S{season}E{episode}: {filename}
The tool now intelligently handles common filename prefixes that may end with digits:
- Problem: For files like
[Group][Series][1155],[Group][Series][1156], etc., the common prefix would be[Group][Series][11, leaving only partial episode numbers (55, 56). - Solution: Automatically removes trailing digits from the common prefix (e.g.,
[Group][Series][11→[Group][Series][), ensuring full episode numbers are extracted.
- Supports episode numbers of any length (2+ digits)
- Handles traditional formats (01-99) and extended numbering (100, 1000+)
- Works with various naming conventions without requiring pattern-specific logic
- The
.plexmatchfile is automatically regenerated on each run - The program automatically skips files containing
[SP]and[MENU]markers - Episode numbers are extracted from filenames using regex (looking for 2 or more consecutive digits)
See LICENSE file for details.