Files

55 lines
1.6 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
智能开发订单班图片重命名脚本
将UUID样式的图片文件名重命名为描述性名称
"""
import os
import shutil
# 图片映射关系基于markdown文档中的描述
image_map = {
"image.jpg": "首页.jpg",
"image 1.jpg": "用户信息后台数据.jpg",
"image 2.jpg": "智能学习数据分析.jpg",
"image 3.jpg": "课程信息后台数据.jpg",
"image 4.jpg": "课程内容.jpg",
"image 5.jpg": "课程直播间.jpg",
"image 6.jpg": "注册界面.jpg",
"image 7.jpg": "热门课程.jpg",
"image 8.jpg": "API配置界面.jpg",
}
# 获取当前脚本所在目录
current_dir = os.path.dirname(os.path.abspath(__file__))
image_dir = os.path.join(current_dir, "image")
print("=" * 60)
print("智能开发订单班图片重命名脚本")
print("=" * 60)
print(f"图片目录: {image_dir}")
print(f"准备重命名 {len(image_map)} 个文件")
print("=" * 60)
# 重命名文件
renamed_count = 0
for old_name, new_name in image_map.items():
old_path = os.path.join(image_dir, old_name)
new_path = os.path.join(image_dir, new_name)
if os.path.exists(old_path):
try:
shutil.move(old_path, new_path)
print(f"{old_name}{new_name}")
renamed_count += 1
except Exception as e:
print(f"✗ 重命名失败: {old_name}{new_name}")
print(f" 错误: {e}")
else:
print(f"⚠ 文件不存在: {old_name}")
print("=" * 60)
print(f"重命名完成: {renamed_count}/{len(image_map)} 个文件")
print("=" * 60)