{"id":26510,"date":"2022-09-10T05:03:31","date_gmt":"2022-09-10T05:03:31","guid":{"rendered":"https:\/\/sambarchi.com\/?p=26510"},"modified":"2022-09-10T05:03:31","modified_gmt":"2022-09-10T05:03:31","slug":"python-automations-making-directories-for-each-working-day-of-the-year","status":"publish","type":"post","link":"https:\/\/sambarchi.com\/?p=26510","title":{"rendered":"Python Automations &#8211; Making Directories for each working day of the year"},"content":{"rendered":"\n<p>Just had a quick one this week I wanted to share. Since I make files for each working day of the year I wanted to automate this so I only had to do it once.<\/p>\n\n\n\n<p>Making Directories using &#8220;os&#8221; (A Python Library).<\/p>\n\n\n\n<p>This one is rather simple in that no added install is needed to get started. As long as you have base Python installed on your machine you are good to go. <br><br>This method will allow you to create directories that have any names you wish in any order you wish. I used it to make the names of directories. <\/p>\n\n\n\n<p>Here is the code I used to accomplish this (it&#8217;s simpler than I thought it would be).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"904\" src=\"http:\/\/sambarchi.com\/wp-content\/uploads\/2022\/09\/folder-flat-design-icon-2103508-1024x904.png\" alt=\"folder, flat design, icon-2103508.jpg\" class=\"wp-image-26524\" srcset=\"https:\/\/sambarchi.com\/wp-content\/uploads\/2022\/09\/folder-flat-design-icon-2103508-1024x904.png 1024w, https:\/\/sambarchi.com\/wp-content\/uploads\/2022\/09\/folder-flat-design-icon-2103508-300x265.png 300w, https:\/\/sambarchi.com\/wp-content\/uploads\/2022\/09\/folder-flat-design-icon-2103508-768x678.png 768w, https:\/\/sambarchi.com\/wp-content\/uploads\/2022\/09\/folder-flat-design-icon-2103508-720x636.png 720w, https:\/\/sambarchi.com\/wp-content\/uploads\/2022\/09\/folder-flat-design-icon-2103508.png 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Making Files sounds like a boring task you learn first but in this case it actually helps me out greatly and saves me time in the long term<\/figcaption><\/figure>\n\n\n\n<p><code>import os<br><br>root_path = '\/Users\/user\/documents' #the root path goes here I am on a mac so it looks like so.<br>folders = ['file1','file2','file3',] #name folders<br>for folder in folders:<br>>>>os.mkdir(os.path.join(root_path,folder))<\/code><\/p>\n\n\n\n<p>Feel free to copy this code and paste it into your own text editor to play around with it! \ud83d\ude00<\/p>\n\n\n\n<p>To name the folders (technically directories) that you are making, simply replace the names of the &#8216;files&#8217; with what you prefer. You can also create more directories than the number I have here. eg I used this code to make files named 1st 2nd 3rd and did this 12 times. Feel free to copy and paste this into your own text editors.<\/p>\n\n\n\n<p>Looking forward to sharing more automations in the future! Be sure to stay tuned. The next one will be on punching in and out at work with a simple python script. Slowly turning the tasks of the day into automations one at a time. \ud83d\ude42<\/p>\n\n\n\n<p>Let me know if you have any questions!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just had a quick one this week I wanted to share. Since I make files for each working day of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_uag_custom_page_level_css":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[1],"tags":[],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"airi-720":false,"airi-360-360":false,"airi-850-485":false,"airi-390-280":false,"airi-969-485":false},"uagb_author_info":{"display_name":"sambarchi@gmail.com","author_link":"https:\/\/sambarchi.com\/?author=1"},"uagb_comment_info":3,"uagb_excerpt":"Just had a quick one this week I wanted to share. Since I make files for each working day of [&hellip;]","_links":{"self":[{"href":"https:\/\/sambarchi.com\/index.php?rest_route=\/wp\/v2\/posts\/26510"}],"collection":[{"href":"https:\/\/sambarchi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sambarchi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sambarchi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sambarchi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26510"}],"version-history":[{"count":2,"href":"https:\/\/sambarchi.com\/index.php?rest_route=\/wp\/v2\/posts\/26510\/revisions"}],"predecessor-version":[{"id":26528,"href":"https:\/\/sambarchi.com\/index.php?rest_route=\/wp\/v2\/posts\/26510\/revisions\/26528"}],"wp:attachment":[{"href":"https:\/\/sambarchi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sambarchi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sambarchi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}