{"id":108,"date":"2026-10-12T12:00:00","date_gmt":"2026-10-12T12:00:00","guid":{"rendered":"https:\/\/top.fadah.store\/?p=108"},"modified":"2026-10-12T12:00:00","modified_gmt":"2026-10-12T12:00:00","slug":"python-script-clean-organize-downloads","status":"publish","type":"post","link":"https:\/\/top.fadah.store\/?p=108","title":{"rendered":"Building an Automated Folder Cleaner in Python to Organize Downloads Daily"},"content":{"rendered":"<p>Like most developers, my <code>Downloads<\/code> folder quickly turns into an unrecognizable wasteland of installers, PDFs, ZIP archives, and random screenshots. I wrote a small background daemon in Python to automatically sort files into neat subdirectories based on extension.<\/p>\n<h2>The Python Cleaner Script<\/h2>\n<pre class=\"wp-block-code\"><code class=\"language-python\">import os\nimport shutil\nfrom pathlib import Path\n\nDOWNLOADS_DIR = Path.home() \/ \"Downloads\"\n\nDIRECTORIES = {\n    \"Documents\": [\".pdf\", \".docx\", \".txt\", \".xlsx\", \".csv\"],\n    \"Images\": [\".jpg\", \".png\", \".jpeg\", \".webp\", \".svg\"],\n    \"Archives\": [\".zip\", \".tar\", \".gz\", \".rar\", \".7z\"],\n    \"Executables\": [\".exe\", \".msi\", \".dmg\"],\n    \"Code\": [\".py\", \".json\", \".sql\", \".env\"]\n}\n\ndef organize():\n    for item in DOWNLOADS_DIR.iterdir():\n        if item.is_file():\n            ext = item.suffix.lower()\n            for folder, extensions in DIRECTORIES.items():\n                if ext in extensions:\n                    target_dir = DOWNLOADS_DIR \/ folder\n                    target_dir.mkdir(exist_ok=True)\n                    shutil.move(str(item), str(target_dir \/ item.name))\n                    break\n\nif __name__ == \"__main__\":\n    organize()\n    print(\"Downloads organized successfully!\")<\/code><\/pre>\n<p>I set this script to run silently on system startup using Windows Task Scheduler. My desktop and downloads folder have stayed clean ever since.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like most developers, my Downloads folder quickly turns into an unrecognizable wasteland of installers, PDFs, ZIP archives, and random screenshots. I wrote a small background daemon in Python to automatically sort files into neat subdirectories based on extension. The Python Cleaner Script import os import shutil from pathlib import Path DOWNLOADS_DIR = Path.home() \/ &#8220;Downloads&#8221; &#8230; <a title=\"Building an Automated Folder Cleaner in Python to Organize Downloads Daily\" class=\"read-more\" href=\"https:\/\/top.fadah.store\/?p=108\" aria-label=\"Read more about Building an Automated Folder Cleaner in Python to Organize Downloads Daily\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[8,28,27,9],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-python","tag-automation","tag-os","tag-productivity","tag-python"],"_links":{"self":[{"href":"https:\/\/top.fadah.store\/index.php?rest_route=\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/top.fadah.store\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/top.fadah.store\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/top.fadah.store\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/top.fadah.store\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108"}],"version-history":[{"count":0,"href":"https:\/\/top.fadah.store\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions"}],"wp:attachment":[{"href":"https:\/\/top.fadah.store\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/top.fadah.store\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/top.fadah.store\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}