From 6ccb46fb1a3a21fd031127585b757df717e4f061 Mon Sep 17 00:00:00 2001 From: Jason Best Date: Mon, 1 Feb 2021 15:25:01 -0600 Subject: [PATCH] fixes #2 empty/missing directory --- barcode-simple.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/barcode-simple.py b/barcode-simple.py index 27c1a52..8f24568 100644 --- a/barcode-simple.py +++ b/barcode-simple.py @@ -437,8 +437,11 @@ def walk(path=None): # files_processed is number of files which match the expected extensions for image files print('Files processed:', files_processed) print('Renames attempted:', renames_attempted) -print('Renames failed:', renames_failed, '({:.1%})'.format(renames_failed/renames_attempted)) -print('Missing barcodes:', missing_barcodes, '({:.1%})'.format(missing_barcodes/files_analyzed)) +if renames_attempted > 0: + print('Renames failed:', renames_failed, '({:.1%})'.format(renames_failed/renames_attempted)) + print('Missing barcodes:', missing_barcodes, '({:.1%})'.format(missing_barcodes/files_analyzed)) +else: + print('Input directory not found or contains no images matching search pattern.') print('Duration:', analysis_end_time - analysis_start_time) if files_analyzed > 0: print('Time per file:', (analysis_end_time - analysis_start_time) / files_analyzed)