A modern file organization tool that automatically sorts files into category-specific subfolders. Inspired by the need for clean directory structures in developer workflows and educational environments.
This script organizes files in any specified folder by moving them into subfolders based on their file extensions. Designed for developers who value clean workspaces, it demonstrates practical use of Python's pathlib for robust file handling.
- Modern path handling with
pathlib
for cross-platform compatibility - Prevents file overwrites by skipping existing items
- Creates subfolders only when needed (no empty directories)
- Handles all file types - from
.txt
to.jpg
- Clear console feedback with move/skip status
git clone https://github.com/fahadelahikhan/An-Arithmetic-Formatter-Project.git
cd An-Arithmetic-Formatter-Project
- Edit
target_folder
in the script to your desired path - Run:
python main.py
After configuring target_folder = Path(r'/Users/me/Documents')
:
# Console output:
Moved: report.pdf -> PDF Files/
Skipped: cat.jpg already exists in JPG Files/
Moved: notes.txt -> TXT Files/
Rearranging Completed!!
- Path Validation: Checks if target folder exists
- File Processing:
- Iterates through all files in directory
- Extracts file extension to determine category
- Creates
[EXTENSION] Files
subfolder if missing
- Safe Moving:
- Uses
shutil.move
for actual file transfer - Skips files that already exist in destination
- Uses
Files without extensions remain in the root directory. Hidden files (starting with .
) are ignored.
Distributed under the MIT License.
Safety First: While this script prevents overwrites, always back up critical files before running organization tools. Concurrent file operations in other programs may cause unexpected behavior.