Add default path
This commit is contained in:
parent
ffd8cc2a82
commit
5b609e6594
1 changed files with 8 additions and 5 deletions
|
@ -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:
|
||||
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.')
|
||||
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("Doesn't seem to be an image.")
|
||||
|
||||
|
|
Loading…
Reference in a new issue