我想将所有.doc文件从特定文件夹转换为.docx文件。
我尝试使用以下代码,
import subprocess
import os
for filename in os.listdir(os.getcwd()):
if filename.endswith('.doc'):
print filename
subprocess.call(['soffice', '--headless', '--convert-to', 'docx', filename])
Run Code Online (Sandbox Code Playgroud)
但是它给了我一个错误:OSError:[Errno 2]没有这样的文件或目录
我想从word文件中的评论中删除所有个人信息。
删除作者姓名很好,我使用以下内容做到了这一点,
document = Document('sampleFile.docx')
core_properties = document.core_properties
core_properties.author = ""
document.save('new-filename.docx')
Run Code Online (Sandbox Code Playgroud)
但这不是我需要的,我想删除在该单词文件中发表评论的任何人的姓名。
我们手动执行此操作的方法是进入首选项-> 安全性-> 保存时从此文件中删除个人信息