create folder later
This commit is contained in:
parent
30a45370be
commit
e8d400fed3
1 changed files with 1 additions and 2 deletions
|
@ -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'(?P<year>20[0-9]{2})[\-/\._]?(?P<month>[0-1]?[0-9])[\-/\._]?(?P<day>[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:
|
||||
|
|
Loading…
Reference in a new issue