main
黄海 8 months ago
parent 93fcab72a9
commit e115ffd712

@ -35,17 +35,18 @@ def repairWord(docPath):
if __name__ == '__main__':
# 遍历工作目录下所有的docx
# 1、修复两层扩展名.docx
for file in os.listdir(workingPath):
if file.endswith('.docx'):
if file.endswith('.docx.docx'):
# 完整的路径名称
docPath = os.path.join(workingPath, file)
# 如果完整的文件名是以.docx.docx结尾的就修改为.docx结尾
if docPath.endswith('.docx.docx'):
docPath = docPath.replace('.docx.docx', '.docx')
print("文件名有误,已修复:" + docPath)
os.rename(docPath, docPath.replace('.docx.docx', '.docx'))
print("正在修复文档:" + file)
docPath = docPath.replace('.docx.docx', '.docx')
print("文件名有误,已修复:" + docPath)
os.rename(docPath, docPath.replace('.docx.docx', '.docx'))
# 2、修复图表异常问题
for file in os.listdir(workingPath):
if file.endswith('.docx'):
# 开始修复文档
repairWord(docPath)
print("修复完成")

Loading…
Cancel
Save