From e74a35771ba8f4959a4bd660914325acbdfba3fa Mon Sep 17 00:00:00 2001 From: lichaojun Date: Fri, 4 Oct 2024 02:19:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20py=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E9=99=90=E5=88=B6=E6=95=B0=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- py-src/config.py | 2 ++ py-src/ppt_to_img.py | 6 ++++++ 2 files changed, 8 insertions(+) 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