Hi there! This is my very first Python project. As a beginner developer with experience in Lua, I decided to dive into Python to create something practical that solves a real-world problem: folder clutter.
This script is a powerful automation tool for the Command Prompt (CMD). It scans a directory provided by the user and automatically moves files into specific folders based on their extensions (e.g., .jpg goes to Images, .pdf to Documents, etc.).
If a folder doesn't exist yet, the script creates it on the fly. Files with unknown extensions are safely left in the main directory.
- Smart Categorization: Uses a dictionary to map multiple extensions to friendly folder names.
- Safe Execution: It checks if the item is a file before moving, avoiding errors with subdirectories.
- Automatic Folder Creation: Uses
pathlib'smkdir(exist_ok=True)to ensure the process never crashes if a folder already exists. - User Feedback: Prints real-time updates in the terminal about which files were moved and which extensions are missing from the mapping.
I wanted to explore how Python handles system files compared to Lua. This project helped me understand:
- Object-Oriented Path Manipulation: Using the
pathliblibrary. - File System Utilities: Using
shutilfor moving data. - Data Structures: Using Dictionaries to create clean and editable configuration mappings.
- Logical Flow: Handling user input and looping through directory iterations.
- Make sure you have Python 3.10+ installed.
- Clone this repository:
git clone https://github.com/arthurzero210/file-organizer-python
- Run the script:
python main.py
- Enter the full path of the directory you want to organize when prompted.
Currently, the script supports:
- Images:
.jpg,.jpeg,.png - Videos:
.mp4 - Sounds:
.mp3,.wav - Documents:
.pdf,.txt - Compacteds:
.zip,.rar - Scripts:
.py,.js,.lua
Note: You can easily add more extensions by editing the extensions dictionary in the source code!
β¨ This project is a milestone in my journey as a programmer. Feel free to leave a star or suggest improvements!