From 5ec372c8d24582622391e977dc04e6d4af994f75 Mon Sep 17 00:00:00 2001 From: Deepakraghavan01 <57013229+Deepakraghavan01@users.noreply.github.com> Date: Fri, 31 Oct 2025 01:21:55 +0530 Subject: [PATCH 1/3] Add automatic file organization for Downloads folder This script organizes files in the user's Downloads folder into categorized subfolders based on file type, such as Images, Documents, Videos, Music, Archives, Applications, and Others. --- .../auto_organize_downloads.py | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 Auto_File_Organizer_#1747/auto_organize_downloads.py diff --git a/Auto_File_Organizer_#1747/auto_organize_downloads.py b/Auto_File_Organizer_#1747/auto_organize_downloads.py new file mode 100644 index 0000000..92a285a --- /dev/null +++ b/Auto_File_Organizer_#1747/auto_organize_downloads.py @@ -0,0 +1,97 @@ +""" +This script automatically organizes files in the user's Downloads folder +by moving them into categorized subfolders based on file type. + +Example: + A file named 'photo.jpg' will be moved to the 'Images' folder. + A file named 'report.pdf' will be moved to the 'Documents' folder. + +Supported categories: + - Images + - Documents + - Videos + - Music + - Archives + - Applications + - Others +""" + +import os +import shutil +from pathlib import Path + +def organize_downloads(downloads_path: str) -> None: + """ + Organize files in the specified Downloads folder by file type. + + Args: + downloads_path (str): The path to the user's Downloads folder. + + Returns: + None + """ + # Define file categories and their associated extensions + categories = { + "Images": [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg"], + "Documents": [".pdf", ".doc", ".docx", ".txt", ".ppt", ".pptx", ".xls", ".xlsx", ".csv"], + "Videos": [".mp4", ".mkv", ".avi", ".mov", ".wmv", ".flv"], + "Music": [".mp3", ".wav", ".aac", ".flac", ".ogg", ".m4a"], + "Archives": [".zip", ".rar", ".tar", ".gz", ".7z"], + "Applications": [".exe", ".msi", ".dmg", ".pkg", ".app"], + } + + # Convert path string to Path object for easier handling + downloads_dir = Path(downloads_path) + + # Validate that the provided path is a directory + if not downloads_dir.is_dir(): + print(f"Error: '{downloads_path}' is not a valid directory.") + return + + # List all files in the Downloads folder (ignore subfolders) + files = [f for f in downloads_dir.iterdir() if f.is_file()] + + if not files: + print("No files found in the Downloads folder.") + return + + # Iterate over files and move them into categorized folders + for file_path in files: + file_extension = file_path.suffix.lower() # e.g., '.jpg' + destination_folder = None + + # Determine which category the file belongs to + for category, extensions in categories.items(): + if file_extension in extensions: + destination_folder = downloads_dir / category + break + + # If no matching category, move to "Others" + if not destination_folder: + destination_folder = downloads_dir / "Others" + + # Create the destination folder if it doesn't exist + destination_folder.mkdir(exist_ok=True) + + # Construct the new file path + destination_path = destination_folder / file_path.name + + try: + # Move the file to the categorized folder + shutil.move(str(file_path), str(destination_path)) + print(f"Moved: {file_path.name} β†’ {destination_folder.name}/") + except Exception as e: + print(f"Error moving {file_path.name}: {e}") + + print("\n Downloads folder organized successfully!") + + +if __name__ == "__main__": + # Default path to the user's Downloads folder + user_downloads = str(Path.home() / "Downloads") + + print("Automatic Downloads Organizer") + print(f"Target folder: {user_downloads}\n") + + # Run the organizer function + organize_downloads(user_downloads) From e6902602dc47f78e7f2e2ae04349dc29d6f6270f Mon Sep 17 00:00:00 2001 From: Deepakraghavan01 <57013229+Deepakraghavan01@users.noreply.github.com> Date: Fri, 31 Oct 2025 01:24:50 +0530 Subject: [PATCH 2/3] Add README for Automatic Downloads Organizer Added README.md to provide project overview and usage instructions. --- Auto_File_Organizer_#1747/README.md | 121 ++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Auto_File_Organizer_#1747/README.md diff --git a/Auto_File_Organizer_#1747/README.md b/Auto_File_Organizer_#1747/README.md new file mode 100644 index 0000000..2413bcc --- /dev/null +++ b/Auto_File_Organizer_#1747/README.md @@ -0,0 +1,121 @@ +--- + +# Automatic Downloads Organizer + +> A Python utility that automatically organizes your **Downloads** folder by moving files into categorized subfolders based on their type. + +--- + +## Features + +* Automatically detects and categorizes files by extension +* Creates folders for each category (e.g., *Images*, *Documents*, *Videos*, *Music*, etc.) +* Moves files into their respective folders +* Works across **Windows**, **macOS**, and **Linux** +* No external libraries required β€” uses Python’s built-in modules + +--- + +## 🧩 Categories and File Types + +| Category | File Extensions | +| ---------------- | ------------------------------------------------------------------------- | +| **Images** | `.jpg`, `.jpeg`, `.png`, `.gif`, `.bmp`, `.tiff`, `.svg` | +| **Documents** | `.pdf`, `.doc`, `.docx`, `.txt`, `.ppt`, `.pptx`, `.xls`, `.xlsx`, `.csv` | +| **Videos** | `.mp4`, `.mkv`, `.avi`, `.mov`, `.wmv`, `.flv` | +| **Music** | `.mp3`, `.wav`, `.aac`, `.flac`, `.ogg`, `.m4a` | +| **Archives** | `.zip`, `.rar`, `.tar`, `.gz`, `.7z` | +| **Applications** | `.exe`, `.msi`, `.dmg`, `.pkg`, `.app` | +| **Others** | Any unsupported or unknown file type | + +--- + +## Example + +### Before: + +``` +photo.jpg +report.pdf +song.mp3 +video.mp4 +installer.exe +randomfile.xyz +``` + +### After running the script: + +``` +Downloads/ +β”œβ”€β”€ Images/ +β”‚ └── photo.jpg +β”œβ”€β”€ Documents/ +β”‚ └── report.pdf +β”œβ”€β”€ Music/ +β”‚ └── song.mp3 +β”œβ”€β”€ Videos/ +β”‚ └── video.mp4 +β”œβ”€β”€ Applications/ +β”‚ └── installer.exe +└── Others/ + └── randomfile.xyz +``` + +--- + +## How It Works + +1. Scans your **Downloads** folder for all files. +2. Determines each file’s type based on its extension. +3. Automatically creates category folders (if missing). +4. Moves files into their appropriate folders. +5. Displays a summary of all moved files in the terminal. + +--- + +## Usage + +### 1. Clone or Download the Script + +Download or copy `organize_downloads.py` to your computer. + +### 2. Run the Script + +Open a terminal or command prompt and run: + +```bash +python organize_downloads.py +``` + +### 3. Output Example + +``` +Automatic Downloads Organizer +Target folder: /Users/Downloads + +Moved: photo.jpg β†’ Images/ +Moved: resume.pdf β†’ Documents/ +Moved: song.mp3 β†’ Music/ +Moved: installer.exe β†’ Applications/ + +Downloads folder organized successfully! +``` + +--- + +## Requirements + +* **Python 3.6+** +* Works on **Windows**, **macOS**, and **Linux** +* Uses built-in modules: `os`, `shutil`, and `pathlib` β€” no installation needed + +--- + +## Notes + +* Files are **moved**, not copied β€” back up if necessary. +* Only organizes files directly in the **Downloads** folder (not subfolders). +* Skips already-organized files inside existing category folders. +* Make sure the script has permission to modify the Downloads folder. + +--- From 47bf3ef48682b4e3704ee59fb4d5f7a3f443dd43 Mon Sep 17 00:00:00 2001 From: Deepakraghavan01 <57013229+Deepakraghavan01@users.noreply.github.com> Date: Fri, 31 Oct 2025 01:25:55 +0530 Subject: [PATCH 3/3] Clean up README formatting Removed unnecessary line from README. --- Auto_File_Organizer_#1747/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Auto_File_Organizer_#1747/README.md b/Auto_File_Organizer_#1747/README.md index 2413bcc..c43a3d5 100644 --- a/Auto_File_Organizer_#1747/README.md +++ b/Auto_File_Organizer_#1747/README.md @@ -1,4 +1,3 @@ ---- # Automatic Downloads Organizer