58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
from pathlib import Path
|
|
import json
|
|
|
|
from data.path_constant import DOWNLOAD_DIR, NETWORK_DIR, TEMP_DOWNLOAD_DIR
|
|
|
|
# DUNGEON_HOME = Path('E:/') / 'Webtoon' / '地下城見聞錄'
|
|
|
|
# for i in range (114, 115):
|
|
# name = str(i) + '.' + '第' + str(i + 1) + '话'
|
|
# path = Path(DUNGEON_HOME) / name
|
|
# path.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
# for first_level_path in TEMP_DOWNLOAD_DIR.iterdir():
|
|
# if first_level_path.is_dir():
|
|
# data_path = first_level_path / 'information.json'
|
|
|
|
# with open(data_path, 'r', encoding='utf-8') as file:
|
|
# data = json.load(file)
|
|
|
|
# # 2. 修改属性名
|
|
# if 'thumbnail_name' in data:
|
|
# data['thumbnail'] = data.pop('thumbnail_name')
|
|
|
|
# # 3. 保存修改后的 JSON 文件
|
|
# with open(data_path, 'w', encoding='utf-8') as file:
|
|
# json.dump(data, file, ensure_ascii=False, indent=4)
|
|
|
|
# print("属性名已修改并保存!")
|
|
|
|
# for first_level_path in DOWNLOAD_DIR.iterdir():
|
|
# if first_level_path.is_dir():
|
|
# print(first_level_path.name)
|
|
|
|
|
|
# HOME = Path('E:/') / 'Webtoon' / '鄰居是公會成員' / '65.第66話'
|
|
|
|
# for img_path in HOME.iterdir():
|
|
# print(img_path.name)
|
|
|
|
# for file in HOME.glob("*.webp"): # 仅遍历 .webp 文件
|
|
# new_name = f"{file.stem.split(' ')[0]}{file.suffix}"
|
|
# # new_name = f"{(int(file.stem) - 1):03d}{file.suffix}" # 转换为 3 位数
|
|
# new_path = file.with_name(new_name) # 生成新路径
|
|
# file.rename(new_path) # 重命名文件
|
|
# print(f"重命名: {file.name} → {new_name}")
|
|
|
|
# print("所有文件已重命名完毕!")
|
|
|
|
# HOME = Path('E:/') / 'Webtoon' / '鬼夜曲'
|
|
HOME = NETWORK_DIR / '鬼夜曲'
|
|
for episode in HOME.iterdir():
|
|
if episode.is_dir():
|
|
index = int(episode.name.split(".")[0])
|
|
if index > 65:
|
|
new_name = f"{index}.第{index - 3}話"
|
|
new_path = HOME / new_name
|
|
episode.rename(new_path) |