Skip to content

Rename tool to rename files to follow plex's standard naming convention.

Notifications You must be signed in to change notification settings

BelardoA/RenameTool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.md

pylint example workflow

Video File Renamer

This project is a Python-based tool designed to rename video files within subdirectories to follow the SXXEXX format, which is commonly used by media servers like Plex. The tool parses video file information, determines the new name based on the season and episode numbers, and renames the files accordingly.

Features

  • Parses video file information including season (from the directory of the file), episode number, and episode name.
  • Renames video files to follow the SXXEXX format.
  • Supports various video file types such as .mp4, .mkv, .wmv, and more.
  • Provides a command-line interface (CLI) for easy usage.

Installation

  1. Clone the repository:

    git clone https://github.com/BelardoA/RenameTool
    cd RenameTool
  2. Install the required dependencies:

    pip install .

Usage

Please Note

The path to the files must be structured as /path/to/show. Within /path/to/show, there should be season folders containing the video files. The season folder names are used to number the episodes. Using the following structure:

tree /path/to/show
├── Season 01
│   ├── episode1.mp4
│   ├── episode2.mkv
│   └── episode3.wmv
├── Season 02
│   ├── episode4.mp4
│   ├── episode5.mkv
│   └── episode6.wmv
└── Season 03
    ├── episode7.mp4
    ├── episode8.mkv
    └── episode9.wmv

Command-Line Interface

The tool provides a CLI for renaming video files. Use the following command to rename files within a specified root directory:

python rename_tool rename_from_root --root <path-to-root-directory>

You will be prompted to enter the directory if not provided.

Example

python rename_tool rename_from_root --root /path/to/video/files

This would rename the files to the following format:

tree /path/to/show
├── Season 01
│   ├── episode1.mp4  -->  S01E01.mp4
│   ├── episode2.mkv  -->  S01E02.mkv
│   └── episode3.wmv  -->  S01E03.wmv
├── Season 02
│   ├── episode4.mp4  -->  S02E01.mp4
│   ├── episode5.mkv  -->  S02E02.mkv
│   └── episode6.wmv  -->  S02E03.wmv
└── Season 03
    ├── episode7.mp4  -->  S03E01.mp4
    ├── episode8.mkv  -->  S03E02.mkv
    └── episode9.wmv  -->  S03E03.wmv

Approach

  1. VideoFile Class: A Pydantic model that represents a video file with attributes such as season, episode, file path, and new name. It includes a method to determine the new name based on the season and episode numbers.

  2. Functions:

    • parse_episode_number_and_name: Parses the episode number and name from the file name using regular expressions.
    • get_video_files: Retrieves video files from the specified directory, organizes them by season, and creates VideoFile instances.
    • rename_files: Renames the video files based on the new name determined by the VideoFile class.
  3. CLI: Uses the click library to create a command-line interface for renaming video files. The rename_from_root command walks through the provided root directory and renames all video files within the season sub-folders.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Rename tool to rename files to follow plex's standard naming convention.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages