Three years ago, I didn't know a single line of code. Now I write Python scripts every day — automating work, scraping data, building bots. And it all started with one tiny script.
I needed to rename 500 photo files. Doing it manually? Madness. An hour of work. Maybe two. And then I remembered hearing about this thing called Python...
I wrote my first script in 20 minutes. It did the work in 5 seconds. At that moment, I realized: this is magic. And now I want you to try it too.
Step 1. Installing Python
Before writing code, you need to install Python. It's very simple:
For macOS
- Open Terminal
- Enter
brew install python - Or download the installer from python.org
For Linux
sudo apt update
sudo apt install python3 python3-pip
After installation, open the terminal and check:
python --version
# or
python3 --version
If you see a Python version — it's working!
Step 2. Your First Python Program
Open any text editor. Create a file hello.py and write:
print("Hello, world!")
Save the file. Open the terminal in the folder with the file and run:
python hello.py
You'll see:
Hello, world!
Congratulations! You just wrote your first Python program. 🎉
What Is a Script and How Is It Different from a Program
A script is a program that automates a specific task. The difference between a script and a regular program is blurry, but generally:
-
Script
Does one specific task, often automates routine work
-
Program
More complex application with a user interface
Step 3. Real Task: Automation
Let's write a script that renames all files in a folder. This is one of the most useful things you can automate.
Imagine you have a folder with files:
IMG_001.jpg
IMG_002.jpg
IMG_003.jpg
...
And you want them to be named:
2026_08_10_001.jpg
2026_08_10_002.jpg
2026_08_10_003.jpg
...
Here's the script code:
import os
from datetime import datetime
# Folder with files
folder = "path_to_folder"
# Get list of files
files = os.listdir(folder)
# Filter only images
images = [f for f in files if f.endswith(('.jpg', '.png', '.jpeg'))]
# Sort for order
images.sort()
# Rename
today = datetime.now().strftime("%Y_%m_%d")
for i, old_name in enumerate(images, start=1):
old_path = os.path.join(folder, old_name)
new_name = f"{today}_{i:03d}.jpg"
new_path = os.path.join(folder, new_name)
os.rename(old_path, new_path)
print(f"Renamed: {old_name} → {new_name}")
print("Done! All files have been renamed.")
Copy this code, replace "path_to_folder" with the actual path, and run it.
Important: Test it on a copy of your files first! You don't want to accidentally rename something important.
How This Script Works — Breakdown
Import Libraries
import os
from datetime import datetime
os — file operations. datetime — for dates.
Specify Folder
folder = "path_to_folder"
Replace with the path to your folder.
Get File List
files = os.listdir(folder)
Returns all files in the folder.
Rename
os.rename(old_path, new_path)
Changes the file name.
Next Level: User Interaction
Let's make the script more useful — add user input:
import os
# Ask the user
folder = input("Enter path to folder: ")
if not os.path.exists(folder):
print("Error: folder not found!")
exit()
# Ask for prefix
prefix = input("Enter prefix for files (e.g., 'photo_'): ")
files = os.listdir(folder)
count = 0
for old_name in files:
old_path = os.path.join(folder, old_name)
if os.path.isfile(old_path):
name, ext = os.path.splitext(old_name)
new_name = f"{prefix}{count:03d}{ext}"
new_path = os.path.join(folder, new_name)
os.rename(old_path, new_path)
count += 1
print(f"{old_name} → {new_name}")
print(f"Done! Renamed {count} files.")
Now the script asks the user which folder to process and what prefix to use.
What Other Scripts Can You Write?
Here's a list of ideas I started with:
| Task | Difficulty | Libraries |
|---|---|---|
| File renaming | ⭐ Easy | os |
| Sort files into folders | ⭐ Easy | os, shutil |
| Web scraping | ⭐⭐⭐ Hard | requests, beautifulsoup4 |
| Excel automation | ⭐⭐ Medium | openpyxl, pandas |
| Send emails | ⭐⭐ Medium | smtplib |
| Telegram bot | ⭐⭐⭐ Hard | python-telegram-bot |
| Backup automation | ⭐⭐ Medium | os, shutil, zipfile |
Where to Learn More
If you enjoyed this, here are resources to help you grow:
- Python is the best language for beginners. Simple, free, powerful.
- Start by installing Python and writing "Hello, world!".
- Automate real tasks — file renaming, sorting, scraping.
- Practice every day — even 15 minutes makes a difference.
- Python can automate almost anything you do manually.
Frequently Asked Questions
Can I learn Python from scratch?
Yes. Python is the simplest language to start with. It reads like English.
How long does it take to learn Python?
Basics — 2-3 weeks. Simple scripts — 1-2 days. Further depends on your goals.
What can I automate with Python?
Almost anything you do manually: files, spreadsheets, websites, emails, bots.
Is Python free?
No. Python is completely free and open-source.
What are the most useful Python libraries for beginners?
os, requests, pandas, openpyxl, beautifulsoup4.
In Conclusion
I started with a simple script to rename files. Now I automate everything that can be automated. Python gave me a superpower — doing in 5 seconds what used to take hours.
You can too. Just try it. Write your first script today. Tomorrow will be easier. And in a month, you'll be amazed at how much you can automate.
By the way, if you need ready-made tools for work — check out our free online tools. They can come in handy even without Python.