diff --git a/image_classifier/image_classifier.py b/image_classifier/image_classifier.py index 3c34aa9..1e2a365 100755 --- a/image_classifier/image_classifier.py +++ b/image_classifier/image_classifier.py @@ -128,13 +128,19 @@ class image_classifier: os.makedirs(person_path) self._log.info(f"Copying file '{file}' to person '{person}' folder,\ '{person_path}'...") - shutil.copy(file, person_path) + try: + shutil.copy(file, person_path) + except FileNotFoundError as error: + self._log.error(f"Error copying. File not found. {error}") if not self.no_move: if os.path.exists(os.path.join(new_path, filename)): self._log.debug(f"Destination '{new_path}/{filename}' exists, removing it...") os.remove(os.path.join(new_path, filename)) self._log.info(f"Moving file '{file}' to '{new_path}'...") - shutil.move(file, new_path) + try: + shutil.move(file, new_path) + except FileNotFoundError as error: + self._log.error(f"Error copying. File not found. {error}") else: self._log.info(f"NOT moving file '{file}' to '{new_path}' because of --no-move")