Skip to content

04-18: File Organizer

Python: Fundamentals

View the live site — ijk37.com

Project 18

Home  |  All Projects  |  Notes  |  Exercises  |  Quiz Hub

Scans a directory and moves files into category sub-folders based on extension (Images, Videos, Audio, Documents, Code, etc.). Includes dry-run preview, conflict-safe renaming, and an undo/flatten mode.

Topics covered: pathlib.Path · shutil.move() · Path.glob() · Path.mkdir(exist_ok=True) · Path.suffix · dict mapping · functions · Path.touch()

Difficulty: ⭐⭐ Intermediate


How to Run

python main.py

Use option 1 to create a demo folder with dummy files.


Extension Categories

Folder Extensions
Images .jpg .png .gif .svg
Documents .pdf .docx .txt
Code .py .html .js .css
Archives .zip .rar .tar .gz
Others anything not matched

Key Concepts Practised

Concept Where used
Path.glob("*") List top-level files
Path.suffix.lower() Get file extension
Path.mkdir(exist_ok=True) Create folders on demand
shutil.move(src, dst) Move files
dict.setdefault(key, []).append() Group files by category
Conflict handling Rename loop with _1, _2 suffix