{"id":114,"date":"2025-10-25T07:29:33","date_gmt":"2025-10-25T07:29:33","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=114"},"modified":"2025-10-25T07:29:33","modified_gmt":"2025-10-25T07:29:33","slug":"02-real-world-python-projects-file-organizer","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=114","title":{"rendered":"02 &#8211; Real-World Python Projects &#8211; File Organizer"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\ud83c\udfaf <strong>Project Objective<\/strong><\/h3>\n\n\n\n<p>To create a Python application that <strong>automatically organizes files<\/strong> in a folder based on their type, demonstrating:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>File and directory management<\/li>\n\n\n\n<li>Use of <code>os<\/code> and <code>shutil<\/code> modules<\/li>\n\n\n\n<li>Loops, conditionals, and functions<\/li>\n\n\n\n<li>Practical automation for daily tasks<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Project: File Organizer App<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Project Description<\/strong><\/h3>\n\n\n\n<p>The File Organizer app <strong>scans a directory<\/strong> and moves files into folders based on their file type. For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Images \u2192 <code>Images<\/code> folder<\/li>\n\n\n\n<li>Documents \u2192 <code>Documents<\/code> folder<\/li>\n\n\n\n<li>Videos \u2192 <code>Videos<\/code> folder<\/li>\n\n\n\n<li>Others \u2192 <code>Others<\/code> folder<\/li>\n<\/ul>\n\n\n\n<p>This helps <strong>keep folders neat and manageable<\/strong> automatically.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Python Example Code<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import os\nimport shutil\n\n# Define file type categories\nFILE_TYPES = {\n    \"Images\": &#91;\".jpg\", \".jpeg\", \".png\", \".gif\", \".bmp\"],\n    \"Documents\": &#91;\".pdf\", \".docx\", \".txt\", \".xlsx\", \".pptx\"],\n    \"Videos\": &#91;\".mp4\", \".mkv\", \".mov\", \".avi\"],\n    \"Audio\": &#91;\".mp3\", \".wav\", \".aac\"]\n}\n\n# Path to organize\npath_to_organize = r\"C:\\Users\\YourName\\Downloads\"\n\n# Loop through files\nfor filename in os.listdir(path_to_organize):\n    file_path = os.path.join(path_to_organize, filename)\n    \n    # Skip directories\n    if os.path.isdir(file_path):\n        continue\n    \n    # Identify file type\n    moved = False\n    for folder, extensions in FILE_TYPES.items():\n        if filename.lower().endswith(tuple(extensions)):\n            folder_path = os.path.join(path_to_organize, folder)\n            if not os.path.exists(folder_path):\n                os.makedirs(folder_path)\n            shutil.move(file_path, folder_path)\n            moved = True\n            break\n    \n    # If file type not recognized\n    if not moved:\n        others_path = os.path.join(path_to_organize, \"Others\")\n        if not os.path.exists(others_path):\n            os.makedirs(others_path)\n        shutil.move(file_path, others_path)\n\nprint(\"Files have been organized successfully!\")\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u2705 Key Features<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Organizes <strong>any folder<\/strong> automatically<\/li>\n\n\n\n<li>Categorizes files based on <strong>extension<\/strong><\/li>\n\n\n\n<li>Creates folders if they don\u2019t exist<\/li>\n\n\n\n<li>Handles <strong>unknown file types<\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\ud83c\udfaf Project Objective To create a Python application that automatically organizes files in a folder based on their type, demonstrating: Project: File Organizer App Project Description The File Organizer app scans a directory and moves files into folders based on their file type. For example: This helps keep folders neat and manageable automatically. Python Example [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-114","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=114"}],"version-history":[{"count":1,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions\/115"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}