Skip to content

Commit

Permalink
在 replace_image_link.py 中新增功能:在更新Markdown文件中的图片链接后,删除原始图片源文件并记录日志。这增强…
Browse files Browse the repository at this point in the history
…了脚本的功能性和清理能力。
  • Loading branch information
W1ndys committed Jan 11, 2025
1 parent e5348ef commit d6974f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions replace_image_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def update_markdown_images(md_file_path):
logging.info(f"将图片链接 {image_path} 替换为 {new_image_link}")
# 替换Markdown中的图片链接
content = content.replace(image_path, new_image_link)

# 删除图片源文件
os.remove(absolute_image_path)
logging.info(f"已删除图片源文件: {absolute_image_path}")
else:
logging.warning(f"图片路径 {absolute_image_path} 不存在")

Expand Down

0 comments on commit d6974f2

Please sign in to comment.