main
黄海 9 months ago
parent 93fcab72a9
commit e115ffd712

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

Loading…
Cancel
Save