From 4566bb2916ddd777af5976baa0c88b4c7ec6c9e2 Mon Sep 17 00:00:00 2001 From: Av-nish <75440657+Av-nish@users.noreply.github.com> Date: Fri, 9 Sep 2022 19:11:10 +0530 Subject: [PATCH] Update docx2txt.py The directory for storing pics does not exist, so it earlier threw an error. This has also been reported by someone in the issues. --- docx2txt/docx2txt.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docx2txt/docx2txt.py b/docx2txt/docx2txt.py index 0dac072..a9fe052 100755 --- a/docx2txt/docx2txt.py +++ b/docx2txt/docx2txt.py @@ -93,9 +93,16 @@ def process(docx, img_dir=None): for fname in filelist: if re.match(footer_xmls, fname): text += xml2text(zipf.read(fname)) - + + # extract images if img_dir is not None: - # extract images + + #Create directory. + try: + os.mkdir(img_dir) + except: + pass + for fname in filelist: _, extension = os.path.splitext(fname) if extension in [".jpg", ".jpeg", ".png", ".bmp"]: