#!/usr/bin/env python
import click
import codecs
import docx2txt

from nlppln.utils import create_dirs, out_file_name


@click.command()
@click.argument('in_files', nargs=-1, type=click.Path(exists=True))
@click.argument('out_dir', nargs=1, type=click.Path())
def command(in_files, out_dir):
    create_dirs(out_dir)

    for fi in in_files:
        text = docx2txt.process(fi)

        out_file = out_file_name(out_dir, fi, 'txt')
        with codecs.open(out_file, 'wb', encoding='utf-8') as f:
            f.write(text)
            f.write('\n')


if __name__ == '__main__':
    command()

@@ -335,16 +335,33 @@
 _files:%0A
+        try:%0A    
         
@@ -397,16 +397,20 @@
         
+ 
+   
 out_file
@@ -446,16 +446,20 @@
  'txt')%0A
+    
         
@@ -519,32 +519,36 @@
  f:%0A            
+  
+  
 f.write(text)%0A  
@@ -545,16 +545,20 @@
 e(text)%0A
+    
         
@@ -575,16 +575,127 @@
 e('%5Cn')%0A
+        except Exception as e:%0A            click.echo('Error in file: %7B%7D'.format(fi))%0A            click.echo(e)
 %0A%0Aif __n

Update worddocx2txt to ignore doc files