]> apps.delaporte.us Git - dotfiles.git/commitdiff
Skip already processed files
authorEdward Delaporte <edward@delaporte.us>
Tue, 24 Feb 2026 02:52:10 +0000 (20:52 -0600)
committerEdward Delaporte <edward@delaporte.us>
Tue, 24 Feb 2026 02:52:10 +0000 (20:52 -0600)
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'