diff --git a/image_classifier/image_classifier.py b/image_classifier/image_classifier.py index 28d9216..088a291 100755 --- a/image_classifier/image_classifier.py +++ b/image_classifier/image_classifier.py @@ -92,8 +92,6 @@ class image_classifier: original_date = self.metadata['Exif.Photo.DateTimeOriginal'].value self._log.debug(f"File creation time: {original_date} (type: {type(original_date)})") new_path = os.path.join(dirname, original_date.strftime('%Y/%m/%d'), filename) - self._log.debug(f"New path: {new_path}") - os.makedirs(os.path.dirname(new_path), exist_ok=True) if not new_path: match = re.search(r'(?P20[0-9]{2})[\-/\._]?(?P[0-1]?[0-9])[\-/\._]?(?P[0-3]?[0-9])', filename) if match: @@ -104,6 +102,7 @@ class image_classifier: new_path = os.path.join(dirname, match.group('year'), match.group('month'), match.group('day'), filename) if not new_path: new_path = os.path.join(dirname, 'unknown-time', filename) + os.makedirs(os.path.dirname(new_path), exist_ok=True) self._log.info(f"Moving file '{file}' to '{new_path}'...") shutil.move(file, new_path) else: