An Emotion Leak.

Goodbye, Clutter

Technology 25

Do you often look for a file in your Downloads folder, wait for Windows to load the plethora of files in it, scan through the unorganized mess and wish that your files get miraculously get organized? Sigh, what a long sentence! But yeah you’ve been through it. I’ve been through it. Read along, thank me later.

It is a myth that computer programs are hard to write and languages like Python have proven it time and again. Python is a fun language to automate your day-to-day stuff and make your life easier. Today we’ll be seeing how to write a Python3 script that magically sorts your Downloads folder once in every two hours.

TL;DR

This is for those who want to just automate the organizing task. This code works for Windows, Linux and macOS users, but I’m going to show only how to set this up to run automatically on Windows. You’ll need Python 3.x version installed on your PC.

  1. https://gist.github.com/pranavsricharan/33d88f3a2789aacd998b9c8a9041ef20

    Copy the above code snippet and save it to a file (say organize_downloads.pyw).

    Note: It is important that the file extension is pyw and not py

  2. Open your run menu (Win Key + R)

  3. Type shell:startup and press enter

  4. Right click anywhere on your window and choose New > Shortcut

  5. Enter the location to the script that you saved (say D:\organize_downloads.pyw)

  6. Give a name for the shortcut file and press Finish

  7. Restart your computer or sign out and sign back in

That’s it. Now the script starts running every time you open your computer and stays running in the background. Once in every two hours, the script checks your Downloads folder and organizes it.

Code Breakdown

  • The first few lines of the code imports the necessary packages for the script to run. All the packages comes pre-installed on a default Python installation

  • Then we find the location of the user directory and the downloads folder

  • The FILE_EXT_MAP is the place where the magic happens. It contains a dictionary of lists. The key to every dictionary will be a new directory where the list corresponding to defines the extensions of the files that will be put in it

  • TIME_INTERVAL defines the interval at which the script must check for files and organize them. The default is set to 7200 seconds (2 hours) but you can change it to your need

  • The next few lines of the defines the function which checks for the file’s extension and moves it to the corresponding directory based on the FILE_EXT_MAP

  • The if __name__ == ‘__main__’ block of the program is the main part of the program. It lists the files present in the downloads folder and passes it to the function we defined above

If you want the script only to be run when you wish to sort the downloads folder and not always then you can do the following:

  • You can skip the steps 2-7 completely

  • Remove the following lines of code

    • TIME_INTERVAL = 7200

    • while True:

    • time.sleep(TIME_INTERVAL)

Hope this helped you clean your downloads folder without breaking a sweat. You can also extend this concept to organize your Desktop which would be covered in a different post.

12 Comments

  1. Mass da machi…

  2. Enjoyed reading through this, very good stuff, thankyou .

  3. I simply want to mention I’m all new to blogging and definitely loved your website. Likely I’m planning to bookmark your site . You definitely have fabulous well written articles. Appreciate it for sharing your blog site.

  4. Thanks for your article. It is extremely unfortunate that over the last decade, the travel industry has already been able to to tackle terrorism, SARS, tsunamis, flu virus, swine flu, along with the first ever real global economic depression. Through it the industry has proven to be robust, resilient as well as dynamic, finding new solutions to deal with hardship. There are usually fresh issues and opportunities to which the industry must once more adapt and act in response.

  5. I am continuously invstigating online for tips that can benefit me. Thx!

  6. I just wanted to send a remark to say thanks to you for those marvelous guidelines you are posting on this website. My time intensive internet search has at the end of the day been recognized with extremely good concept to write about with my company. I would express that many of us site visitors are truly lucky to live in a fine network with many lovely professionals with useful ideas. I feel extremely blessed to have come across your entire website and look forward to so many more awesome moments reading here. Thank you again for all the details.

  7. Thanks a lot for providing individuals with remarkably memorable opportunity to check tips from this website. It really is very excellent and as well , packed with fun for me and my office co-workers to visit your blog nearly thrice weekly to read through the newest tips you will have. And lastly, I am also certainly fulfilled with the sensational things served by you. Selected 1 tips in this article are basically the finest we have all ever had.

  8. My husband and i have been very ecstatic Ervin could deal with his inquiry because of the precious recommendations he got through your weblog. It’s not at all simplistic just to always be offering tips and hints which usually other folks could have been making money from. And we also acknowledge we have got you to thank for that. All the explanations you have made, the simple blog navigation, the relationships your site make it possible to create – it’s got everything superb, and it’s making our son in addition to us know that this topic is awesome, and that’s tremendously indispensable. Many thanks for all the pieces!

  9. Stendra Ed No Physician Approval For Sale Birmingham Viagra Avec Ou Sans Prescription viagra Celexa Online Pharmacy Cialis Cuanto Tomar

  10. I have to show my appreciation to you just for rescuing me from such a condition. Just after surfing through the world wide web and meeting concepts that were not productive, I was thinking my life was over. Existing minus the answers to the issues you’ve solved through your entire guideline is a crucial case, and the ones that would have in a negative way damaged my career if I had not come across your web blog. Your training and kindness in handling every item was useful. I am not sure what I would’ve done if I had not come upon such a solution like this. I am able to at this time relish my future. Thanks very much for this impressive and results-oriented help. I won’t be reluctant to propose your site to any individual who requires assistance about this problem.

  11. I simply had to thank you very much once more. I’m not certain the things I could possibly have made to happen without these pointers contributed by you concerning my subject matter. It has been a very troublesome condition in my view, but looking at your specialised fashion you dealt with it made me to cry over joy. I’m just happier for this information and in addition hope you really know what a powerful job you were providing teaching many others through the use of a site. Probably you haven’t got to know any of us.

Leave a Reply

Your email address will not be published. Required fields are marked *

All rights reserved to Wanderersink