diff --git a/py-src/config.py b/py-src/config.py index bf0b9d4..87d4d50 100644 --- a/py-src/config.py +++ b/py-src/config.py @@ -2,9 +2,11 @@ import os class Config: + RANGE_NUM: int = 20 WORK_PATH = "E:/商品资料汇总/商品资料(1101-1150)" # WORK_PATH = "C:/Users/Administrator/Desktop/测试" + @staticmethod def get_latest_folder(base_directory): folders = [ os.path.join(base_directory, d) diff --git a/py-src/ppt_to_img.py b/py-src/ppt_to_img.py index 05b8048..c4d9a32 100644 --- a/py-src/ppt_to_img.py +++ b/py-src/ppt_to_img.py @@ -31,14 +31,20 @@ def ppt2png(pptFileName, downLoad_path, powerpoint): # 批量转换PPT文件 def batch_convert_ppt_to_png(directory, output_directory): powerpoint = init_powerpoint() + conversion_count = 0 # 初始化转换计数器 # 遍历指定目录中的所有PPT和PPTX文件 for filename in os.listdir(directory): if filename.endswith(".ppt") or filename.endswith(".pptx"): + if conversion_count >= Config.RANGE_NUM: + print("已达到最大转换限制。") + break # 如果达到最大转换次数,则停止 + pptFileName = os.path.join(directory, filename) downLoad_path = os.path.join( output_directory, os.path.splitext(filename)[0] ) # 不带扩展名的文件名 + conversion_count += 1 # 转换计数器加1 ppt2png(pptFileName, downLoad_path, powerpoint) powerpoint.Quit() # 退出PowerPoint