Organize Files in any Folder by File Type

Automatically sort files into folders by file type using Python.

November 5, 2025
3 min read
automationfile-system

How to use this Trick

You can copy the code below, or download the Full Project for the best experience.

1. ConfigureUse the inputs below to customize the code variables.
2. DownloadGet the zip file containing the source code.
3. Run (Windows)Unzip and double-click run_windows.bat.
3. Run (Mac/Linux)Unzip and double-click run_mac.command.

Configuration

Code Editor (python)

Download Full Project

Get the complete source code with your configuration applied. Includes one-click runner scripts for Windows and macOS.

run_windows.batrun_mac.command100% Open Source

Overview

This Python script helps you automatically organize files in a folder by their type. No more messy folders!

How it Works

  1. Scans the folder - The script reads all files in the specified directory. You can copy the folder path and then paste it to file_path input box above.
  2. Identifies file types - This code udentifies and categories folders based on file extensions. If you need specific floder names for category please enter folder name you want: [relevant extensions for it seperated by comma] in above code console under file type mappings
  3. Creates folders - Makes folders for each category. If you don't give specific folder name this will automatically give names for folders based on extension.
  4. Moves files - Automatically sorts files into their respective folders

Step-by-Step Guide

Step 1: Install Python

Make sure you have Python 3.6+ installed on your system. If not download python from here.

Step 2: Customize Settings

Use the inputs above to specify your folder path and organization method.

Step 3: Run the Script

Next download the package and unzip it. Here you have few ways you can run the script.

If you are not familiar with coding, -Windows users can just double click on run_windows bat file and script will run automatically. -Mac or Linux users can just double click on run_mac.command file and script will run automatically.

If you like coding

  1. Open the package in code editor like visual studio code.
  2. Here also you have two options. Manually setup everything or just run follwing command in bash.
./setup.sh && python main.py

Step 4: Check Results

Your files will now be organized into neat folders! Check out!

File Types

Here we have added following file types by default.

  • Images: .jpg, .png, .gif, .svg
  • Documents: .pdf, .docx, .txt, .xlsx
  • Videos: .mp4, .avi, .mkv
  • Audio: .mp3, .wav, .flac
  • Archives: .zip, .rar, .7z
  • Code: .py, .js, .html, .css

All other files that don't have above extensions will go to folder called Others. So if you need another Different folder to be created for specific extension type you can add that in the filetypes dictionary. Below given example.

Let's say we want to move colab Notebooks to folder called Notebooks. Then we have to add that in the file_types variable as below.

file_types = {
'Images': ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.svg'],
'Documents': ['.pdf', '.doc', '.docx', '.txt', '.xlsx', '.pptx'],
'Videos': ['.mp4', '.avi', '.mkv', '.mov'],
'Audio': ['.mp3', '.wav', '.flac', '.aac'],
'Archives': ['.zip', '.rar', '.7z', '.tar', '.gz'],
'Code': ['.py', '.js', '.html', '.css', '.java', '.cpp'],
'Notebooks': ['.ipynb'] // <= new line added. if you have more extensions please seperate them by comma.
}

You can add Files and corresponding extensions as you like. Files with Extensions not in the file_types will be moved to folder called Others.

Tips & Tricks

  • You can customize the file_types dictionary to add more categories
  • Run the script regularly to keep your folders organized

If you think you missed some file_types to add and if you want to reverse the process and do it again, use this code.

Configuration

Code Editor (python)

Download Full Project

Get the complete source code with your configuration applied. Includes one-click runner scripts for Windows and macOS.

run_windows.batrun_mac.command100% Open Source

🎥Video Tutorial

Related Tricks