How to Automate Your Python Scripts for Free (2021)
By: Christopher Zita
Tags: Time, Automation, Free, Python, Data Science

In this article, I’m going to show you how you can automate your Python scripts for Free. The reason why I’m putting an emphasis on free is that there are a lot of programs and websites that can actually do this for you online, but nearly all of them require a fixed fee for you to use their applications.

And since I know most people don’t want to spend that type of money, I instead found a unique way that this can be done for free, so you can automate your Python scripts to run every day at a certain time, or every week, or every month.

This unique way just involves 2 simple steps.

1. Creating a Batch File for Your Python Script

A batch file is a list of commands that are processed in sequence often without requiring user input or intervention. To create a batch file for the Python script you want to automate you need two pieces of information.

File path of your Python application File path of your Python script

We want these two pieces of information because the batch file with first go to the file path of our Python application and start-up Python. It will then go to the file path of our Python script and run that Python program in the started up Python application.

To get the file path of your Python application you need to go to where Python is saved in your files from when you initially installed it. You should be looking for a file that looks like this.

It should also have the extension python.exe. To give you an example of what the file path should look like, this is the file path for my Python application.

C:\Users\chris\Anaconda4\python.exe

After you get that file path, you need to get the file path of the Python script you want to automate. This should be much easier to find, and I’ll show you an example of what one of my file paths look like.

C:\chris\Documents\Automate_Python_Scripts.py

When you have those 2 pieces of information, you then need to open up your notepad which should be accessible through your search bar. It will look like this..

Then all you have to do is copy your two file paths and paste them in the notepad on the same line with space in between the two. You will then have to put quotation marks (“these are quotation marks”) around both file paths, and make sure to change the slashes from \ to / if they are not already. In the end, this is what your first line should look like in the notepad…

After this line is inputted into the notepad, save the notepad, but you have to change the extension it will give you of .txt to .bat to create a batch file. So let’s say I want to save this notepad as note1, you would then save it as..

note1.bat

If you did everything correctly your notepad should now come up as a Windows Batch File as so…

2. Setting Up a Task in the Task Scheduler

After you have officially created a batch file for your Python script, you now need to create a task in the Task Scheduler.

Task Scheduler is an app that your computer should have that has all the tasks that your computer runs daily. To access it, it’s similar to the notepad as it should be accessible through your search bar. If you opened up the right app it should look like this...