diff --git a/scripts/image_migrate.py b/scripts/image_migrate.py index cb63ff32..1d0fed97 100755 --- a/scripts/image_migrate.py +++ b/scripts/image_migrate.py @@ -672,13 +672,18 @@ def create_example_config(config_file: str): def read_image_paths(image_list_file: str) -> List[str]: """从文件读取图片路径列表""" paths = [] + not_images = [] try: with open(image_list_file, "r", encoding="utf-8") as f: for line in f: line = line.strip() if line and not line.startswith("#"): - paths.append(line) - print(f"从文件读取 {len(paths)} 个图片路径") + if not line.endswith((".png", ".jpeg", ".jpg", ".gif", ".webp")): + not_images.append(line) + else: + paths.append(line) + print(f"从文件中读取到 {len(paths)} 个图片路径数据行") + print(f"从文件中读取到 {len(not_images)} 个非图片路径数据行") except Exception as e: print(f"读取图片路径文件失败 {image_list_file}: {e}") return paths @@ -889,9 +894,14 @@ def main(): print("请使用 --input 指定文件或直接在命令行提供路径") sys.exit(1) + origin_paths = image_paths # 去重 image_paths = list(set(image_paths)) + repeats = len(origin_paths) - len(image_paths) + if repeats > 0: + print(f"从文件中读取到 {repeats} 个重复图片路径数据行") + # 创建并运行迁移器 migrator = ImageMigrator( source_config=source_config,