豁然高

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

使用python删除文件(xlsx,xlsm,pptx,pptm,docx)个人信息

库安装命令

复制代码
yum install python-pip
pip install --upgrade pip
pip install -U setuptools

pip install python-pptx
pip install python-docx
pip install openpyxl

sudo pip install --upgrade lxml
复制代码

 

 

 

delete_private_info_for_docx.py

复制代码
#!/usr/bin/python
# -*- coding: UTF-8 -*-

# #docx
from docx import Document
import sys

fileName = sys.argv[1]

prs = Document(fileName)

#print(prs.core_properties.author)
#print(prs.core_properties.last_modified_by)

prs.core_properties.author = ""
prs.core_properties.last_modified_by = ""

prs.save(fileName)
复制代码

 

delete_private_info_for_pptm.py

复制代码
#!/bin/python
# -*- coding: utf-8 -*-

from pptx import Presentation
import sys


fileName = sys.argv[1]
print(fileName)

prs = Presentation(fileName)


print(prs.core_properties.author)
print(prs.core_properties.last_modified_by)

prs.core_properties.author = ""
prs.core_properties.last_modified_by = ""

prs.save(fileName)
复制代码

 

delete_private_info_for_pptx.py

复制代码
#!/bin/python
# -*- coding: utf-8 -*-

from pptx import Presentation
import sys


fileName = sys.argv[1]
print(fileName)

prs = Presentation(fileName)


print(prs.core_properties.author)
print(prs.core_properties.last_modified_by)

prs.core_properties.author = ""
prs.core_properties.last_modified_by = ""

prs.save(fileName)
复制代码

 

delete_private_info_for_xlsm.py

复制代码
#!/bin/python
# -*- coding: utf-8 -*-

from openpyxl import load_workbook
import sys

fileName = sys.argv[1]
print(fileName)
wb = load_workbook(fileName, keep_vba=True)

wb.properties.creator=""
wb.properties.last_modified_by=""

wb.save(fileName)
复制代码

 

delete_private_info_for_xlsx.py

复制代码
#!/bin/python
# -*- coding: utf-8 -*-

from openpyxl import load_workbook
import sys

fileName = sys.argv[1]
print(fileName)
# wb = load_workbook(fileName, keep_vba=True)
wb = load_workbook(fileName)

wb.properties.creator=""
wb.properties.last_modified_by=""


wb.save(fileName)
复制代码

 

posted on   豁然高  阅读(707)  评论(0编辑  收藏  举报

编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示