豁然高

导航

使用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 2020-11-26 15:20  豁然高  阅读(648)  评论(0编辑  收藏  举报