Python实现图片批量重命名+统一改名,简单好用图片整理工具

前言

不管是拍照素材、截图、网图、产品图片,时间久了之后文件名杂乱,全是乱码、数字、英文,查看和使用非常不方便。

手动一个个改名又慢又累,还容易改错顺序。

今天给大家分享一款纯Python写的图片批量重命名工具,不用复杂配置,代码复制就能直接运行,可以统一前缀、有序编号,自动保留图片后缀,安全不损坏原图,零基础也能上手,适合日常自用+发文。

一、实现功能

批量修改文件夹内所有图片名称

自定义统一前缀+数字递增编号

自动保留原图格式后缀不变

只处理图片文件,不会改动其他文档

运行安全,不删除、不损坏原始图片

原生模块实现,无需额外安装复杂依赖

二、运行环境

仅使用Python内置 os 模块

无需pip安装第三方库

Python3 全部版本通用,Windows直接运行

三、完整可运行代码

import os

图片格式筛选列表

img_suffix = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp"]

def rename_images(folder_path, prefix="图片"):

count = 1

获取文件夹所有文件

file_list = os.listdir(folder_path)

for file in file_list:

获取文件后缀

suffix = os.path.splitext(file)[1].lower()

只处理图片文件

if suffix in img_suffix:

old_path = os.path.join(folder_path, file)

new_name = f"{prefix}_{count}{suffix}"

new_path = os.path.join(folder_path, new_name)

os.rename(old_path, new_path)

print(f"{file} >>> {new_name}")

count += 1

print("图片批量重命名全部完成!")

if name == "main":

在这里修改你的图片文件夹路径

target_folder = r"D:\picture"

自定义改名前缀

name_prefix = "风景素材"

rename_images(target_folder, name_prefix)

四、使用方法

https://gitee.com/nomeans/tea-tasting/issues/IJBSW8

https://gitee.com/nomeans/tea-tasting/issues/IJBSW6

https://gitee.com/nomeans/tea-tasting/issues/IJBSW3

https://gitee.com/nomeans/tea-tasting/issues/IJBSVZ

https://gitee.com/nomeans/tea-tasting/issues/IJBSVW

https://gitee.com/nomeans/tea-tasting/issues/IJBSVT

https://gitee.com/nomeans/tea-tasting/issues/IJBSVS

https://gitee.com/nomeans/tea-tasting/issues/IJBSVO

https://gitee.com/nomeans/tea-tasting/issues/IJBSVJ

https://gitee.com/nomeans/tea-tasting/issues/IJBSVD

https://gitee.com/nomeans/tea-tasting/issues/IJBSV8

https://gitee.com/nomeans/tea-tasting/issues/IJBSV5

https://gitee.com/nomeans/tea-tasting/issues/IJBSV2

https://gitee.com/nomeans/tea-tasting/issues/IJBSV1

https://gitee.com/nomeans/tea-tasting/issues/IJBSUY

https://gitee.com/nomeans/tea-tasting/issues/IJBSUU

https://gitee.com/nomeans/tea-tasting/issues/IJBSUT

https://gitee.com/nomeans/tea-tasting/issues/IJBSUS

https://gitee.com/nomeans/tea-tasting/issues/IJBSUP

https://gitee.com/nomeans/tea-tasting/issues/IJBSUN

https://gitee.com/nomeans/tea-tasting/issues/IJBSUL

https://gitee.com/nomeans/tea-tasting/issues/IJBSUJ

https://gitee.com/nomeans/tea-tasting/issues/IJBSUG

https://gitee.com/nomeans/tea-tasting/issues/IJBSUC

https://gitee.com/nomeans/tea-tasting/issues/IJBSUB

https://gitee.com/nomeans/tea-tasting/issues/IJBSU9

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRZ

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRY

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRX

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRT

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRR

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRP

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRN

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRL

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRI

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRG

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRF

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRE

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRD

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSRA

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSR7

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSR6

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSR1

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQY

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQW

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQV

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQT

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQJ

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQH

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQG

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQF

https://gitee.com/gnoliynil/tea-tasting/issues/IJBSQD

https://gitee.com/jqhph/tea-tasting/issues/IJBSPH

https://gitee.com/jqhph/tea-tasting/issues/IJBSPF

https://gitee.com/jqhph/tea-tasting/issues/IJBSPE

https://gitee.com/jqhph/tea-tasting/issues/IJBSPB

https://gitee.com/jqhph/tea-tasting/issues/IJBSPA

https://gitee.com/jqhph/tea-tasting/issues/IJBSP9

https://gitee.com/jqhph/tea-tasting/issues/IJBSP6

https://gitee.com/jqhph/tea-tasting/issues/IJBSP5

https://gitee.com/jqhph/tea-tasting/issues/IJBSP3

https://gitee.com/jqhph/tea-tasting/issues/IJBSP2

https://gitee.com/jqhph/tea-tasting/issues/IJBSP0

https://gitee.com/jqhph/tea-tasting/issues/IJBSOZ

https://gitee.com/jqhph/tea-tasting/issues/IJBSOV

https://gitee.com/jqhph/tea-tasting/issues/IJBSOU

https://gitee.com/jqhph/tea-tasting/issues/IJBSOT

https://gitee.com/jqhph/tea-tasting/issues/IJBSOP

https://gitee.com/jqhph/tea-tasting/issues/IJBSOL

https://gitee.com/jqhph/tea-tasting/issues/IJBSOK

https://gitee.com/jqhph/tea-tasting/issues/IJBSOJ

https://gitee.com/jqhph/tea-tasting/issues/IJBSOI

https://gitee.com/jqhph/tea-tasting/issues/IJBSO5

https://gitee.com/jqhph/tea-tasting/issues/IJBSO4

https://gitee.com/jqhph/tea-tasting/issues/IJBSO2

https://gitee.com/jqhph/tea-tasting/issues/IJBSNZ

https://gitee.com/jqhph/tea-tasting/issues/IJBSNW

https://gitee.com/jqhph/tea-tasting/issues/IJBSNV

https://gitee.com/wxf8602/tea-tasting/issues/IJBSMS

https://gitee.com/wxf8602/tea-tasting/issues/IJBSMQ

https://gitee.com/wxf8602/tea-tasting/issues/IJBSMO

https://gitee.com/wxf8602/tea-tasting/issues/IJBSMM

https://gitee.com/wxf8602/tea-tasting/issues/IJBSML

https://gitee.com/wxf8602/tea-tasting/issues/IJBSMG

https://gitee.com/wxf8602/tea-tasting/issues/IJBSME

https://gitee.com/wxf8602/tea-tasting/issues/IJBSMD

https://gitee.com/wxf8602/tea-tasting/issues/IJBSM7

https://gitee.com/wxf8602/tea-tasting/issues/IJBSM6

https://gitee.com/wxf8602/tea-tasting/issues/IJBSM4

https://gitee.com/wxf8602/tea-tasting/issues/IJBSM3

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLQ

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLP

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLO

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLL

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLI

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLF

https://gitee.com/wxf8602/tea-tasting/issues/IJBSLD

https://gitee.com/wxf8602/tea-tasting/issues/IJBSL9

https://gitee.com/wxf8602/tea-tasting/issues/IJBSL3

https://gitee.com/wxf8602/tea-tasting/issues/IJBSKX

https://gitee.com/wxf8602/tea-tasting/issues/IJBSKS

https://gitee.com/wxf8602/tea-tasting/issues/IJBSKN

https://gitee.com/wxf8602/tea-tasting/issues/IJBSKJ

https://gitee.com/wxf8602/tea-tasting/issues/IJBSKE

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSH6

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSH5

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSH3

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSH1

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSH0

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSGX

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSGU

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSGQ

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSGM

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSGD

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSGA

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSG7

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSG3

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFY

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFW

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFQ

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFI

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFG

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFD

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFC

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSFB

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSF9

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSF8

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSF7

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSF5

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSF3

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSF2

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEZ

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEY

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEW

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEU

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSET

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSES

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEQ

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEP

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEN

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEM

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEL

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEK

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEI

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEG

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSED

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEB

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSEA

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSE7

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSE5

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSE4

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSE3

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSDT

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSDS

https://gitee.com/sparrowgood/tea-tasting/issues/IJBSDR

新建py文件,把上面代码全部复制进去

修改代码里图片文件夹路径为自己的目录

修改想要统一的中文前缀名称

直接运行代码,自动有序批量改名

五、应用场景

手机导出照片统一规整命名

电商产品图片批量整理

自媒体素材图库分类改名

截图、学习资料图片归档整理

个人相册统一规范化管理

六、优点说明

操作简单,零基础也能使用

速度快,几百张图片几秒完成

原图画质、格式完全不受影响

只针对图片筛选,不会误改其他文件

七、简单拓展思路

增加按修改时间排序后再命名

实现图片批量缩小压缩

自动给图片加上统一水印

递归遍历子文件夹全部图片

八、总结

这款Python图片批量重命名脚本,简单实用、轻量化,是日常整理图库必备的小工具。

告别手动一个个改名字,一键统一格式、有序编号,省心又高效,代码干净无敏感内容,直接复制就能用、能发文。

#Python #Python图片处理 #批量重命名 #办公自动化 #图片整理 #Python小工具 #编程入门

相关推荐
Hugh-Yu-1301232 小时前
WSL --Ubuntu-24.04-LTS子系统安装教程
linux·windows·ubuntu
私人珍藏库13 小时前
[吾爱大神原创工具] QtScreenSwitcher[Win]一个现代化、极简、高颜值的多屏开关工具。
windows·工具·软件·win·多功能
competes13 小时前
慈善基金投资底层逻辑应用 顶层代码低代码配置平台开发结构方式数据存储模块
java·开发语言·数据库·windows·sql
零号全栈寒江独钓15 小时前
基于c/c++实现linux/windows跨平台获取ntp网络时间戳
linux·c语言·c++·windows
dyxal1 天前
内网 Windows 离线安装 uv:极速 Python 包管理器的部署实战
windows·python·uv
stone08231 天前
如何解决Windows硬盘变成了空白
windows
零号全栈寒江独钓1 天前
基于c/c++实现linux/windows跨平台ntp时间戳服务器
linux·c语言·c++·windows
舒一笑1 天前
Windows 下执行 pnpm install 报 EBUSY: resource busy or locked,我最后用这一招解决了
前端·windows·程序员
hERS EOUS1 天前
Redis 下载与安装 教程 windows版
数据库·windows·redis