Project Overview
Organize files into folders automatically using os, shutil, and file extensions.
This beginner Python project helps you practice real coding skills with a small program you can run and modify.
Python Code
import os
import shutil
folder = 'downloads'
for file in os.listdir(folder):
name, ext = os.path.splitext(file)
ext = ext[1:]
if ext:
target = os.path.join(folder, ext)
os.makedirs(target, exist_ok=True)
shutil.move(os.path.join(folder, file), os.path.join(target, file))How to Run This Project
- Install Python.
- Create a new file ending with .py.
- Paste the code into the file.
- Open Command Prompt or Terminal.
- Run the file using python filename.py.
What You Practice
- Python syntax
- Variables and data types
- Conditions and loops
- Functions or modules depending on the project
- Problem solving
Project Improvements
- Add error handling.
- Save data to a file.
- Create a menu system.
- Improve the user interface.
- Convert the project into a GUI or web app later.