]> apps.delaporte.us Git - dotfiles.git/blobdiff - files/ocr/ocr.py
Skip already processed files
[dotfiles.git] / files / ocr / ocr.py
index 795a83b2242fd8e391d588af67f24bb4d596955b..61a69ba41b74f9db1e0211591330c54c0decd2ea 100644 (file)
@@ -27,9 +27,12 @@ def ocr_directory(input_dir):
                 input_path = os.path.join(root, file_name)
                 output_path = os.path.join(root, file_name.replace('.', '_ocr.'))
 
-                # Perform OCR on the image
-                text = ocr_image(ocr, input_path)
-
+                text = None
+                if os.path.exists(output_path):
+                    print(f'{output_path} exists.')
+                else:
+                    # Perform OCR on the image
+                    text = ocr_image(ocr, input_path)
                 if text:
                     # Write the OCR result to a JSON file
                     json_output_path = output_path.rsplit('.', 1)[0] + '.json'