Skip to content

CodeANDCraftHub/FileOrganizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python File Organizer

Organize your messy folders automatically with Python in minutes! This beginner-friendly script sorts files by type, creates folders, and moves everything into place.


Features

  • Auto-organize files by extension
  • Safe workflow with dry-run mode before moving files
  • Timestamped log file to see what changed
  • Duplicate file renaming (file_1, file_2, …)
  • Optional whitelist/skip extensions
  • Works on Windows & macOS

Prerequisites

  • Python 3.x installed
  • Basic command line usage
  • A test folder with mixed files to practice

Libraries Used

  • os — file system operations
  • shutil — move files
  • pathlib — clean path handling
  • datetime — timestamped logs

Installation

  1. Clone this repository:
git clone https://github.com/CodeANDCraftHub/FileOrganizer.git
cd FileOrganizer
  1. Make sure your test folder has some mixed files (or use the included example_folder/).

Example Folder Structure

example_folder/
├── test_image.jpg
├── test_video.mp4
├── test_doc.pdf
├── test_audio.mp3
├── test_script.py
├── test_archive.zip
├── random_file.xyz
├── test_app.exe

How to Run

  1. Open file_organizer.py and set your folder:
SOURCE_DIR = Path.home() / "Downloads"  # or your folder path
  1. Run in dry-run mode first to preview changes:
python file_organizer.py
  1. Check the generated log file to see which files would be moved:
file_organizer_log_YYYYMMDD_HHMMSS.txt
  1. When ready, set:
dry_run = False

and run again to actually move files.


Optional Settings

  • Whitelist extensions to skip certain files:
whitelist_extensions = [".txt", ".md"]
  • Add/Update file types by editing the file_types dictionary in the script.

Real-World Use Cases

  • Clean Downloads or Desktop clutter
  • Batch organize project assets, images, PDFs, and docs
  • Keep screenshot folders tidy

Notes

  • Duplicate files are automatically renamed
  • Safe to re-run: only processes files in the root folder
  • Works on both Windows and macOS (update folder path format as needed)

Next Steps

Check out my Python screenshot automation tool — automatically timestamps and organizes your screenshots.


Links

  • Full script: file_organizer.py
  • Example folder: example_folder/

Support

If this script saved you time, subscribe to Code & Craft Hub on YouTube for more Python automation projects and practical, beginner-friendly scripts.

https://www.youtube.com/@CodeANDCraftHub?sub_confirmation=1

About

Beginner-friendly Python file organizer that sorts files by type, with dry-run and logging.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages