Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs: update README with setup instructions
  • Loading branch information
jaimzh committed Nov 22, 2025
commit b769da094153c8e6207399cb38a1b708131b61de
77 changes: 77 additions & 0 deletions File_Organizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!--Please do not remove this part-->
![Star Badge](https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99)
![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)

# File Organizer
<p align="center">
<img src="assets/filelogo.png" width=40% height=40%>


## 🛠️ Description

The **File Organizer** is a simple Python script that automatically sorts and organizes files in a selected folder based on their file types. The neat freak your computer needs.

It creates categorized subfolders (like **Documents**, **Images**, **Videos**, etc.) and moves files into the right place.


You can,
1. Improve its functionality (e.g., add new categories, GUI, etc.)
2. Fix bugs or optimize the logic
3. Add a new cool feature like a config file

Every contribution counts — even small ones 💪

## ⚙️ Languages or Frameworks Used

This script only uses Python's **standard library** (`os`, `shutil`), so no additional dependencies are required.

## 🌟 How to run

1. Clone the repository and navigate to the folder:
```bash
git clone https://github.com/<your-username>/python-mini-project.git
cd python-mini-project/file_organizer
```

2. Run the script:

```bash
python main.py
```

or, if that doesn’t work:

```bash
python3 main.py
```

3. Enter the folder path you want to organize when prompted.

To stop it, press **CTRL + C**

## 📺 Demo

Some demos of the script in action:

<p align="">
<img src="assets/image1.png" width=40% height=40%>
<img src="assets/image2.png" width=40% height=40%>
<img src="assets/image3.png" width=40% height=40%>
</p>



## 🤖 Author

This script is by **Jaimz**.

Jaimz → [https://github.com/jaimzh](https://github.com/jaimzh)
This is my GitHub profile.








Binary file added File_Organizer/assets/filelogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added File_Organizer/assets/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added File_Organizer/assets/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added File_Organizer/assets/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions File_Organizer/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import shutil

# Customize your categories here
CATEGORIES = {
"Documents": ["pdf", "docx", "txt", "csv", "xlsx", "pptx"],
"Images": ["jpg", "jpeg", "png", "gif", "bmp", "svg"],
"Videos": ["mp4", "mkv", "mov", "avi"],
"Music": ["mp3", "wav", "flac", "aac"],
"Archives": ["zip", "rar", "7z", "tar", "gz"],
"Code": ["py", "js", "html", "css", "cpp", "java"],
"Others": [] # fallback category for unlisted extensions
}

def get_category(extension):
"""Return the matching category for a given file extension."""
for category, extensions in CATEGORIES.items():
if extension in extensions:
return category
return "Others"

def organize_files(folder_path):
"""Organize files by predefined categories."""
if not os.path.isdir(folder_path):
print(f"Error: '{folder_path}' is not a valid directory.")
return

for filename in os.listdir(folder_path):
file_path = os.path.join(folder_path, filename)

if os.path.isdir(file_path):
continue # skip directories

# Get file extension
ext = os.path.splitext(filename)[1].lower().strip('.')
category = get_category(ext)

# Create category folder
target_dir = os.path.join(folder_path, category)
os.makedirs(target_dir, exist_ok=True)

# Move the file
target_path = os.path.join(target_dir, filename)
shutil.move(file_path, target_path)

print(f"Moved: {filename} → {category}/")

print("\nAll files organized successfully!")

if __name__ == "__main__":
path = input("Enter the folder path to organize: ").strip()
organize_files(path)