How to Rename 1000 Files in 10 Seconds with Python - Free Script Inside

`Screenshot showing before and after batch file renaming with Python script


Have you ever downloaded 200 photos from your phone and found them all named "IMG_001", "IMG_002", "IMG_003


It's messy, unprofessional, and a nightmare if you need to find one specific file later


Doing this manually in Windows Explorer or Mac Finder would take you 2-3 hours. You'd have to click, rename, press enter, repeat... 200 times.


But with Python, you can rename all 200 files in 10 seconds with 12 lines of code.


I'm Rehab, an AI and Python developer. I use this exact script every week to organize client projects. Today I'll give you the code for free.


The Problem With Manual File Management


Most people don't realize how much time they waste on repetitive computer tasks.


Let's say you have a folder with 500 screenshots from a client project. You need to rename them to "ClientName_Project_001", "ClientName_Project_002", etc.


Manual method:

- Click file → Press F2 → Type new name → Press Enter

- Repeat 500 times

- Total time: 2.5 hours

- Mistakes: Guaranteed


Python method

- Run script once

- Total time: 10 seconds

- Mistakes: Zero


That's the power of automation.


What You'll Learn in This Tutorial


By the end of this post, you'll have a working Python script that can:

1. Rename unlimited files automatically

2. Add custom prefixes like "Vacation_2025_"

3. Add numbers in order: 001, 002, 003

4. Only target specific file types http://like.jpg http://or.png

5. Work on Windows, Mac, and Linux


The Complete Python Script


Copy this code into Notepad or any text editor:

import os
# SETTINGS - CHANGE THESE TWO LINES
folder_path = "C:/Users/YourName/Downloads
new_name = "Vacation_2025"
count = 1
for filename in os.listdir(folder_path
# Only rename image files. Delete this line to rename ALL files
if filename.lower().endswith((".jpg", ".jpeg", ".png", ".gif", ".heic")):
file_extension = os.path.splitext(filename)[1]
new_filename = f"{new_name}_{count:03d}{file_extension}"
old_path = os.path.join(folder_path, filename)
new_path = os.path.join(folder_path, new_filename)
os.rename(old_path, new_path)
print(f"Renamed: {filename} → {new_filename}")
count += 1
print(f"\nDone! Successfully renamed {count-1} files.")

 )

      

        

Step-by-Step Setup Guide


Step 1: Get Your Folder Path

On Windows: Open the folder, click the address bar at the top, copy the path. It looks like `C:\Users\Rehab\Downloads`

On Mac: Right-click folder → Get Info → Copy the "Where" path


Step 2: Edit the Script

Open the code in Notepad. Change line 5 to your folder path.

Change line 8 to whatever name you want. Use underscores instead of spaces.


Step 3: Save as Python File

Click File → Save As.

File name: `rename_files.py`

Save as type: `All Files (_._)`

Encoding: `UTF-8`

Make sure it ends with `.py` not `.txt`


Step 4: Run the Script

Double-click the file. A black window will pop up for 2 seconds and close.

Check your folder - all files are renamed!


Important Safety Tips


1. *Always backup first*: Copy the folder before running the script. If something goes wrong, you won't lose data.

2. *Test on 5 files*: Create a test folder with 5 dummy files first. Make sure it works before running on 1000 files.

3. *Close other programs*: Don't have the folder open in another program while running the script.

4. *Undo is hard*: Python doesn't have Ctrl+Z. That's why backup matters.


Common Errors and Fixes


Error: "FileNotFoundError"

Fix: Your folder path is wrong. Check for typos and make sure you use forward slashes `/` not backslashes `\` in the code.


Error: "Permission Denied"

Fix: The file is open in another program. Close Photoshop, Word, or File Explorer window showing that folder.


Error: "SyntaxError"

Fix: You missed a quotation mark or bracket when editing the code. Copy the code again carefully.


Why Companies Pay for This Skill


This is called "process automation". Marketing agencies, photographers, and e-commerce stores pay $50-$150/hour for people who can write 20-line scripts like this.


Once you master this, you can automate:

- Sorting downloads into folders by date

- Converting 100 images to PDF

- Backing up files to Google Drive automatically

- Scraping data from websites


All with 20-30 lines of Python.


What's Next


In my next post, I'll show you how to make this script work by right-clicking any folder in Windows. No more editing file paths manually.


If you want that tutorial, leave a comment saying "NEXT" below.


Final Thoughts


You don't need to be a software engineer to automate your life. You just need 30 minutes and the right script.


Save this post, run the code, and save yourself 3 hours next time you have messy files.


*Question for you:* What other boring computer task do you repeat every week? Tell me in the comments and I'll turn it into a free Python script for you.

Comments

Popular posts from this blog

The Blueprint of Agentic AI: How Autonomous Workflows Are Redefining Digital Automation in 2026

How to Build a High-Performance Workflow with AI: A Guide for Freelancers