feat: 批量修改ppt属性
parent
798524ccaa
commit
42ccea0843
@ -0,0 +1,31 @@
|
||||
import os
|
||||
from pptx import Presentation
|
||||
from config import Config
|
||||
from pptx.util import Inches
|
||||
|
||||
def set_slides_prop(ppt_path):
|
||||
prs = Presentation(ppt_path)
|
||||
|
||||
text = "创意素材铺"
|
||||
# 设置文档属性
|
||||
prs.core_properties.title = text
|
||||
prs.core_properties.subject = text
|
||||
prs.core_properties.author = text
|
||||
prs.core_properties.category = text
|
||||
prs.core_properties.keywords = text
|
||||
prs.core_properties.comments = text
|
||||
|
||||
# 保存演示文稿
|
||||
prs.save(ppt_path)
|
||||
print(f"'{os.path.basename(ppt_path)}'设置属性成功")
|
||||
|
||||
|
||||
def batch_set_slides(directory):
|
||||
for filename in os.listdir(directory):
|
||||
if filename.endswith(".pptx") or filename.endswith(".ppt"):
|
||||
ppt_path = os.path.join(directory, filename)
|
||||
set_slides_prop(ppt_path)
|
||||
|
||||
|
||||
# 调用批量删除函数
|
||||
batch_set_slides(Config.get_latest_folder(Config.WORK_PATH))
|
||||
Loading…
Reference in New Issue