diff --git a/assets/copyright-img/2ppt.png b/assets/copyright-img/2ppt.png new file mode 100644 index 0000000..bb41942 Binary files /dev/null and b/assets/copyright-img/2ppt.png differ diff --git a/assets/xlsm_bk.txt b/assets/xlsm_bk.txt new file mode 100644 index 0000000..092ca02 --- /dev/null +++ b/assets/xlsm_bk.txt @@ -0,0 +1,38 @@ +Sub 批量修改母版() + Application.ScreenUpdating = False + newMasterName = "创意素材铺YYDS" ' 指定的新母版名称 + Set fso = CreateObject("scripting.filesystemobject") + Set ff = fso.GetFolder("C:\Users\Administrator\Desktop\test") 'ThisWorkbook.Path是当前代码文件所在路径,路径名可以根据需求修改 + ActiveSheet.UsedRange.ClearContents + + a = 1 + For Each f In ff.Files + If f Like ".ppt" Or f Like ".pptx" Then + ' MsgBox "发现" & f.Name + Set Myppt = CreateObject("PowerPoint.Application") + Myppt.Visible = True + + Set newppt = Myppt.Presentations.Open(Filename:=f) + + + Dim master As Object + For Each master In newppt.Designs + master.Name = newMasterName ' 重命名母版 + Next master + + newppt.Save + newppt.Close + + Set newppt = Nothing + Set Myppt = Nothing + + Cells(a, 1) = f.Name '相对路径名 + Cells(a, 2) = f '全路径名 + a = a + 1 + End If + + Next f + + Application.ScreenUpdating = True + +End Sub diff --git a/assets/批量修改母版.xlsm b/assets/批量修改母版.xlsm new file mode 100644 index 0000000..bad2679 Binary files /dev/null and b/assets/批量修改母版.xlsm differ diff --git a/config/index.js b/config/index.js index 5906572..33f5e0e 100644 --- a/config/index.js +++ b/config/index.js @@ -10,7 +10,7 @@ const config = { * 则直接使用inputDir作为工作目录 */ inputDir: '', - // inputDir: 'E:/商品资料汇总/商品资料(2001-2050)/ppt2005-黄继光', + // inputDir: 'E:\商品资料汇总\商品资料(1201-1250)\ppt1234-海姆立克', // inputDir: 'C:/Users/Administrator/Desktop/test', // 指定要查找的目录 directoryPath: 'E:/商品资料汇总/商品资料(1201-1250)', diff --git a/py-src/del_copyright_img.py b/py-src/del_copyright_img.py index 2cd336a..4679e6b 100644 --- a/py-src/del_copyright_img.py +++ b/py-src/del_copyright_img.py @@ -6,6 +6,8 @@ from PIL import Image import imagehash import os from config import Config +from pptx.opc.constants import RELATIONSHIP_TYPE as RT +from pptx.oxml import parse_xml def get_copyright_image_paths(): # 构建 assets/copyright-img 的相对路径 @@ -60,12 +62,20 @@ def remove_copyright_images(pptx_path, copyright_image_paths): # 定义要删除的关键字符数组(只删除文本框) del_text_keywords = ["Speaker name and title", "OfficePLUS", "Presenter name", "www.officeplus.cn", "第一PPT模板网-WWW.1PPT.COM"] # 定义要删除的关键字符数组(删除整页幻灯片) - del_text_keywords_slide = ["如需商用请您自行向版权方购买、获取商用版权。"] + del_text_keywords_slide = ["模板中使用的字体为开源字体","一站式办公内容服务平台"] + + # 遍历所有幻灯片母版 + # for sld_mstr in prs.slide_masters: + # theme_part = sld_mstr.part.part_related_by(RT.THEME) + # theme = parse_xml(theme_part.blob) + # sld_mstr.name = theme.get("name") + # print(sld_mstr.name) # 遍历每一页幻灯片 for index, slide in enumerate(prs.slides): # 遍历幻灯片中的每个形状 for shape in slide.shapes: + # 检查形状是否为图片 if shape.shape_type == 13: # 13 表示图片 # 临时保存图片 @@ -89,7 +99,6 @@ def remove_copyright_images(pptx_path, copyright_image_paths): # 检查形状是否为文本框 if shape.has_text_frame: text_content = shape.text - print(f"'{os.path.basename(pptx_path)}'在第 {index + 1} 页有文本框,内容为: '{text_content}'") # 检查文本内容是否包含要删除的关键字符数组中的任意字符 if any(char in text_content for char in del_text_keywords_slide):