You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
892 B
Python
32 lines
892 B
Python
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))
|