Keeping your Downloads folder organized can be a tedious task, especially when files accumulate rapidly from different sources like browsers, email attachments, or other apps. Automating the cleanup process using a Python script can save time and reduce clutter effectively.
Here’s a Python script designed to clean up your Downloads folder by sorting files into categorized subfolders based on their file types. It can move documents, images, videos, archives, and more into dedicated folders automatically.
How This Script Works:
-
Folder Path Setup: It sets your Downloads folder path dynamically by detecting your home directory.
-
Categories Definition: Different file extensions are grouped into categories like Images, Videos, Documents, etc.
-
Folder Creation: It creates these category folders inside Downloads if they don’t already exist.
-
File Movement: Each file in Downloads is checked against the extension lists. Files are moved into the matching folder.
-
Unmatched Files: Files with extensions not listed are moved into an “Others” folder.
Usage:
-
Save the script as
clean_downloads.py. -
Run it using Python (Python 3.x recommended):
-
The script will organize your Downloads folder immediately.
Customization Tips:
-
You can add or remove file extensions from the
FILE_CATEGORIESdictionary as needed. -
Modify
DOWNLOADS_FOLDERif your downloads are in a different location. -
Extend functionality by adding file size or date-based filtering if required.
This Python script provides a straightforward and automated way to keep your Downloads folder tidy without manual sorting.