Start Automating Your Life Using Python! (File Management with Python Tutorial)

preview_player
Показать описание

What I love about coding is that it’s not just a skill that can help you build an interesting and lucrative career, but also something that you can use to actually solve real problems that you have in your daily life.

And that’s what automating your life with Python allows you to do, so in this video I will show you how to get started with learning to teach your computer to do the boring and menial tasks you do every day, and we’re going to be doing that via a simple project to automatically organise your computer’s downloads folder.

You might ask, do I need to use Python, and if so why Python?If I know C, Java or Javascript, can I use those to automate my life? And yes, you probably can use other languages, the reason why Python is usually used for these types of applications is that it's easy to learn, has an active community, and has tons of libraries to cover many automation needs.

In addition it’s very simple to write and understand and sort of does a lot for you so you don’t need to worry about low level details like memory management or types for example.

The only downside of Python is that it’s much slower than something like C, but for these simple automation scripts that doesn’t really matter.

But yes, you can probably use other languages, you just need to check that the language has the ability to touch your computer’s file system for example.

I do recommend using Python. It’s a very nice and sleek language.

MY FREE COURSE

OTHER STUDY & CODING RESOURCES
MY BLOG

WHO AM I?
This channel documents my life as a Self-Taught Software Engineer as well as my journey teaching myself Computer Science & Programming.

CHAPTERS:
0:00 Solve Problems using Code
0:50 Why Python?
1:34 SPONSOR: Morning Brew
2:37 What We're Going to Build
3:45 Where to Start when Building Projects
4:30 TUTORIAL: File Downloads Management Automator
11:00 Why I Love Automation Projects
11:40 How to Use Shell Scripting

DISCLAIMER: some of the links in the description may be affiliate links. If you purchase a product or service using the links that I provide I may receive a small commission. This is no extra charge to you! Thanks for supporting Internet Made Coder :)

Tags: python automation projects, automate the boring stuff with python, learn python, python automation, automate your life, learn python fast, python fundamentals, bash scripting, learn to code, coding projets, coding project ideas, python tutorial, desktop automation, coding tutorial, python 101, how to automate tasks for beginners
Рекомендации по теме
Комментарии
Автор

Tell me your Python automation ideas!!!

InternetMadeCoder
Автор

This is not a tutorial about File Management with Python.
This is a tutorial about how bring your Ideas to code step-by-step, which is a very important skill. very nice 👍

smittywerbenjj
Автор

Btw, there's also a book called "How to automate the boring stuff with python", which teaches you how to do these kinds of tasks

sotirioskapartzianis
Автор

You might consider running this as a background process. You could do research onto running scripts as a long running background process. In addition you might consider scheduling this "background script" to run at startup of your computer. Areas of research include "MacOS launch agents" (fancy name for background process; you might also hear the term daemon in Mac world managed using launchd) or crontab to run programs on a schedule.

An alternative you could consider "Startup Apps" which you could search for in MacOS ecosystem that might be a bit more user friendly to get a program to run at startup.

Note you could further refine that as MacOS isn't my daily driver, so there might be a better way to accomplish your goal of further automating your system. As is the case with any problem, there are multiple solutions.

The benefit of running it in the background is that you don't have an extra terminal window minimized.

The benefit of running at startup is that you need not start the script manually.

Great video 👍

RoboDragonJediKnight
Автор

LOVE your description of what got you excited about coding. How you describe having a "superpower" that allows you to tell your computer to perform highly-specific tasks in a way that makes it like having an "unpaid virtual assistant you have access to at all times." You took the words right out of my mouth with that one. That's exactly what excites me about Python, too. Great video!

masqueradinglampshade
Автор

I see you hard coded the differentiation for the type of file based on the file extension. Python actually comes with a library for fetching or guessing the MIME-Type of a file, which not only determines the general type (e.g. text, picture, video), but also the subtypes as text/css. It’s simply called mimetypes.

ansgar
Автор

The first thing you need is a trigger for the downloads folder, something like, if the downloads folder contains an image, move image to the appropriate folder or if the downloads folder contains video, move video to appropriate folder. Really awesome video. Gave me a lot of ideas of how to automate daily tasks with python. Will definitely subscribe.

bobans
Автор

If you want it to always run, setup a CRONTAB job to run every say, 10 seconds. You put the absolute path of the file there and it will run it in It’s directory.

Reecepbcups
Автор

I used pyautogui (a Python automation module) and cURL to download practically all images from a website (almost 3, 000+ images) and automated the process of saving every layer from Photoshop. That's how great python is.

jaycesardo
Автор

As usual you did a great job balancing information with showing actual use cases

paulmilakeve
Автор

I'm a smart but a lazy person, I can't even tell you the lengths I'd go to have a chance to be a bit lazier on a daily basis. When I first started to learn a little bit of programming, my essential goal was to automatise my work, which was writing some really generic texts. Although the work I was doing changed a little bit after that, I liked programming and now I'm thinking about having it as a career path. Still a long way to go, but working on it every day and I'm sure I'll get there one day.

hoochiecoochieman
Автор

In windows cmd
> md "pdf folder"
> move *.pdf "pdf folder"
We can do similarly for other file types also

VamsiKrishna-ppfy
Автор

You could run it periodically as agent in the background I have used it before it is very easy to set up just edit the plist file for that

kameld
Автор

Great video, and a great thought. I’m big on automating, but I always focus on the big things and forget there’s micro-automations that could improve my life like this.

One suggestion I have is, maybe the event that’s triggered that says that a file changed has a property that tells you which file, and you may not need to scan the directory. That would make sense to me, but I’m not as familiar with python to say for sure. Also, you possibly want to make sure the file isn’t still downloading, but most downloaders these days have a temp name and then change to the real name when finished.

brainsniffer
Автор

Great video. Thanks.
I made the mistake of running the program w/o having created the folders so it moved all the files to a file (not a folder) of the same name, but was unusable. Essentially I lost all my files.

Fortunately I had a backup, restored all files and rectified my mistake and it worked perfectly.

Thanks.

ShaneFozard
Автор

Thank you for sharing. I think for me and most beginners is it is easy to get overwelled with programing. This video has made my life a little bit easier.

blackburn
Автор

I don't know if you've found the solution on how to run your program on background i've found one (bc i've done what you've done only with shows, anime etc...) and here it is: you can rename the extension of your python script file to pyw, after that you create the executable and after you run it it will be created as a process in background that you can close through the task manager and if you want it to be started at the start up of your pc you can press WIN+R and type in "shell::startup" and place inside your .exe

tizioacaso
Автор

You can use launchd to start your program automatically when your system starts.

marckramer
Автор

I wish I could automate my OCD obsessions. I'd be free finally.

leonard_
Автор

Good video. I decided to write my own version of the script. I have added a bit more to mine, ensure files are completely downloaded before moving the files. Run each file download on its own thread so that faster file downloads done have to wait until longer downloads are completed first. Added a timeout for each file download, I used tuples for my extensions..why...Tuples are immutable (not chanegable) and allows for the use of the membership operator "in". All in all, what seemed as a simple program to just copy a file turned out into researching how to do several things in python...which is the point...

walkerkler