Fundamentals 4 min read

How to Auto‑Rename Multiple Excel Performance Files with Python in Seconds

This tutorial shows how to use a short Python script to batch‑rename inconsistently named Excel performance reports into a uniform "Name8月绩效.xlsx" format, complete with code, screenshots of before‑and‑after results, and practical tips for asking technical questions.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
How to Auto‑Rename Multiple Excel Performance Files with Python in Seconds

Hello, I'm PiPi.

1. Introduction

In a recent Python group, a user asked how to automatically rename multiple Excel performance files whose names are inconsistent, aiming for a uniform format like "ZhangSan8月绩效.xlsx" or "LaoLiu8月绩效.xlsx".

Below are the screenshots of the original files.

And the image of the provided example.

2. Implementation

One contributor provided the following Python script to rename the files:

import os

name = ["张三", "李四", "王虎", "老六", "二虎"]

file_name = os.listdir(r"C:\Users\pdcfi\Desktop\绩效")

for n in name:
    for file in file_name:
        if n in file:
            os.rename("C:/Users/pdcfi/Desktop/绩效/" + file,
                      "C:/Users/pdcfi/Desktop/绩效/" + n + "8月绩效.xlsx")
            print(f"{n}已经替换完成!")

Running the script produces the expected renamed files, as shown below.

The issue was resolved successfully.

3. Conclusion

This article demonstrated a practical Python automation solution for batch‑renaming Excel performance reports, providing both the problem analysis and a ready‑to‑use code snippet.

When posting questions, it is helpful to provide sanitized demo data, concise code, and error screenshots to facilitate quick assistance.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AutomationScriptingFile Renaming
Python Crawling & Data Mining
Written by

Python Crawling & Data Mining

Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.