Skip to content

Instantly share code, notes, and snippets.

@noahbleau
Created October 22, 2025 15:28
Show Gist options
  • Select an option

  • Save noahbleau/8556edd09aa9dcc86d95b198fe1bc513 to your computer and use it in GitHub Desktop.

Select an option

Save noahbleau/8556edd09aa9dcc86d95b198fe1bc513 to your computer and use it in GitHub Desktop.
Simple Organizer in Python for your series! (Made by ChatGPT)

🎬 Series Organizer Instructions

This folder contains two Python scripts that automatically organize your TV show files into clean folders, ready for your media library.

📁 Folder Structure Example

/DIRECTORY
├── organizeFlixtor.py
├── organizeFormated.py
├── INSTRUCTIONS.md
├── Alice.in.Borderland.2020.S01E01.Pilot.mkv
├── Alice.in.Borderland.2020.S01E02.Next.Game.mkv
├── Alice in Borderland (2020) S02E01 Pilot.mkv
└── Alice in Borderland (2020) S02E02 1988.mkv

🧩 1. Script: organizeFlixtor.py

🎯 Purpose

This script organizes raw, unformatted Flixtor-style (https://Flixtor.to) files (which often contain dots . instead of spaces) into properly named series folders and season subfolders.
It also renames the episodes into a readable format.


✅ Expected File Format

The script detects files using this structure: Title.year.SxxEyy.EpisodeTitle.extension

Examples:

  • Alice.in.Borderland.2020.S01E01.Pilot.mkv
  • Breaking.Bad.2008.S02E03.Bit.by.a.Dead.Bee.mp4
  • The.Last.of.Us.2023.S01E09.Look.for.the.Light.mkv

🧠 How It Works

  1. The script scans all files in the same folder where it’s placed.
  2. It uses a regular expression to detect SxxEyy patterns.
  3. It automatically creates:
    • a series folder: Title (year)
    • a season subfolder: Season xx
  4. It renames and moves each episode into its correct location.

📦 Example: Before / After

Before:

/DIRECTORY
├── organizeFlixtor.py
├── Alice.in.Borderland.2020.S01E01.Pilot.mkv
├── Alice.in.Borderland.2020.S01E02.Next.Game.mkv
├── Alice.in.Borderland.2020.S02E01.Return.mkv
└── Alice.in.Borderland.2020.S02E02.Goodbye.mkv

After:

/DIRECTORY
├── organizeFlixtor.py
└── Alice in Borderland (2020)
├── Season 01
│ ├── Alice in Borderland (2020) S01E01 Pilot.mkv
│ └── Alice in Borderland (2020) S01E02 Next Game.mkv
└── Season 02
├── Alice in Borderland (2020) S02E01 Return.mkv
└── Alice in Borderland (2020) S02E02 Goodbye.mkv

▶️ How to Run

python3 organizeFlixtor.py

The script will display a message for each episode it moves and renames.


🧩 2. Script: organizeFormated.py

🎯 Purpose

This script organizes already properly named files (e.g. Title (year) SxxEyy EpTitle) into their correct season folders without renaming them.


✅ Expected File Format

The script detects files with the following format: Title (year) SxxEyy EpisodeTitle.extension

Examples:

  • Alice in Borderland (2020) S01E01 Pilot.mkv
  • Alice in Borderland (2020) S02E02 1988.mkv
  • Breaking Bad (2008) S01E03 ...And the Bag's in the River.mp4

🧠 How It Works

  1. The script identifies the series title, year, and season number from the filename.
  2. It automatically creates:
    • a series folder: Title (year)
    • a season subfolder: Season xx
  3. It moves the file into the correct folder without changing its name.

📦 Example: Before / After

Before:

/DIRECTORY
│
├── organizeFormated.py
├── Alice in Borderland (2020) S01E01 Pilot.mkv
├── Alice in Borderland (2020) S01E02 Next Game.mkv
├── Alice in Borderland (2020) S02E01 Return.mkv
└── Alice in Borderland (2020) S02E02 Goodbye.mkv

After:

/DIRECTORY
│
├── organizeFormated.py
│
└── Alice in Borderland (2020)
    ├── Season 01
    │   ├── Alice in Borderland (2020) S01E01 Pilot.mkv
    │   └── Alice in Borderland (2020) S01E02 Next Game.mkv
    └── Season 02
        ├── Alice in Borderland (2020) S02E01 Return.mkv
        └── Alice in Borderland (2020) S02E02 Goodbye.mkv

▶️ How to Run

python3 organizeFormated.py

Each file will be moved into its respective season folder.


⚠️ Important Notes

  • Both scripts automatically ignore the following files:
    • organizeFlixtor.py
    • organizeFormated.py
    • INSTRUCTIONS.md
  • Files that don’t match the required pattern will be skipped and shown as “ignored”.
  • No files are deleted — only moved into folders.

💡 Pro Tip

You can safely use both scripts in the same folder:

  1. Run organizeFlixtor.py first to clean up messy Flixtor-style names.

  2. Then run organizeFormated.py to finish sorting already formatted files.


🧰 Combined Example

python3 organizeFlixtor.py
python3 organizeFormated.py

Final result:

/DIRECTORY
├── organizeFlixtor.py
├── organizeFormated.py
├── INSTRUCTIONS.md
└── Alice in Borderland (2020)
    ├── Season 01
    │   ├── Alice in Borderland (2020) S01E01 Pilot.mkv
    │   └── Alice in Borderland (2020) S01E02 Next Game.mkv
    └── Season 02
        ├── Alice in Borderland (2020) S02E01 Return.mkv
        └── Alice in Borderland (2020) S02E02 Goodbye.mkv

🧡 Enjoy your clean, perfectly sorted series library!

Thanks to ChatGPT for this script.

import os
import re
import shutil
root = os.path.dirname(os.path.abspath(__file__))
# Expression régulière pour les épisodes
episode_pattern = re.compile(
r'^(?P<title>.+?)\.(?P<year>\d{4})\.S(?P<season>\d{2})E(?P<episode>\d{2})\.(?P<epTitle>.+?)\.(?P<ext>[^.]+)$',
re.IGNORECASE
)
ignored = {"organizeFlixtor.py", "organizeFormated.py", "INSTRUCTIONS.md"}
def clean(s):
"""Remplace les points multiples et convertit en espaces."""
s = re.sub(r'\.{2,}', '.', s)
s = s.replace('.', ' ').strip()
return s
print("\n🎬 Organisation des séries en cours...\n")
for filename in os.listdir(root):
if filename in ignored or not os.path.isfile(os.path.join(root, filename)):
continue
src = os.path.join(root, filename)
match = episode_pattern.match(filename)
if match:
# Extraire les infos
title = clean(match.group("title"))
year = match.group("year")
season = match.group("season")
episode = match.group("episode")
ep_title = clean(match.group("epTitle"))
ext = match.group("ext")
# Dossiers
series_folder = os.path.join(root, f"{title} ({year})")
season_folder = os.path.join(series_folder, f"Season {season}")
os.makedirs(season_folder, exist_ok=True)
# Nouveau nom
new_name = f"{title} ({year}) S{season}E{episode} {ep_title}.{ext}"
dst = os.path.join(season_folder, new_name)
shutil.move(src, dst)
print(f"✅ Épisode : {filename} → {new_name}")
else:
# Fichiers hors-série (ex: cover.jpg)
series_match = re.match(r'^(?P<title>.+?)\.(?P<year>\d{4})\.', filename)
if series_match:
title = clean(series_match.group("title"))
year = series_match.group("year")
series_folder = os.path.join(root, f"{title} ({year})")
os.makedirs(series_folder, exist_ok=True)
dst = os.path.join(series_folder, filename)
shutil.move(src, dst)
print(f"📦 Fichier ajouté : {filename} → {title} ({year})/")
else:
print(f"⚠️ Ignoré : {filename}")
print("\n✅ Organisation terminée avec succès !")
import os
import re
import shutil
root = os.path.dirname(os.path.abspath(__file__))
# Expression régulière : Série (année) SxxExx
episode_pattern = re.compile(
r'^(?P<title>.+?)\s\((?P<year>\d{4})\)\sS(?P<season>\d{2})E(?P<episode>\d{2}).*\.(?P<ext>[^.]+)$',
re.IGNORECASE
)
# Fichiers à ignorer
ignored = {"organizeFormated.py", "organizeFlixtor.py", "INSTRUCTIONS.md"}
print("\n🎬 Organisation des séries formatées en cours...\n")
for filename in os.listdir(root):
if filename in ignored or not os.path.isfile(os.path.join(root, filename)):
continue
src = os.path.join(root, filename)
match = episode_pattern.match(filename)
if not match:
print(f"⚠️ Ignoré : {filename}")
continue
title = match.group("title").strip()
year = match.group("year")
season = match.group("season")
ext = match.group("ext")
# Création des dossiers
series_folder = os.path.join(root, f"{title} ({year})")
season_folder = os.path.join(series_folder, f"Season {season}")
os.makedirs(season_folder, exist_ok=True)
# Destination (même nom)
dst = os.path.join(season_folder, filename)
# Déplacement
shutil.move(src, dst)
print(f"✅ Déplacé : {filename} → {title} ({year})/Season {season}/")
print("\n✅ Organisation terminée avec succès !")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment