Add default path

This commit is contained in:
Antonio J. Delgado 2021-09-07 00:20:20 +03:00
parent ffd8cc2a82
commit 5b609e6594

View file

@ -98,11 +98,14 @@ class image_classifier:
match = re.search(r'(?P<year>[1-2][0-9]{3})[\-/\._]?(?P<month>[0-1]?[0-9])[\-/\._]?(?P<day>[0-3]?[0-9])', filename)
if match:
new_path = os.path.join(dirname, match.group('year'), match.group('month'), match.group('day'), filename)
if new_path:
if not new_path:
match = re.search(r'(?P<day>[0-3]?[0-9])[\-/\._]?(?P<month>[0-1]?[0-9])[\-/\._]?(?P<year>[1-2][0-9]{3})', filename)
if match:
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)
self._log.info(f"Moving file '{file}' to '{new_path}'...")
shutil.move(file, new_path)
else:
self._log.debug('No new path, so no moving.')
else:
self._log.debug("Doesn't seem to be an image.")