Change date format to use dots
This commit is contained in:
parent
3f62c88516
commit
4fe97384e8
4 changed files with 18 additions and 11 deletions
|
@ -1 +1,7 @@
|
|||
== image_classifier
|
||||
|
||||
Classifies images by their EXIF date (e.g. /path/YYYY.MM.DD/image.jpg).
|
||||
|
||||
= Install
|
||||
|
||||
python3 setup.py install
|
|
@ -90,17 +90,18 @@ class image_classifier:
|
|||
if 'Exif.Photo.DateTimeOriginal' in self.metadata.exif_keys:
|
||||
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)
|
||||
if not new_path:
|
||||
folder = os.path.join(dirname, original_date.strftime('%Y.%m.%d'), filename)
|
||||
if not folder:
|
||||
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:
|
||||
new_path = os.path.join(dirname, match.group('year'), match.group('month'), match.group('day'), filename)
|
||||
if not new_path:
|
||||
match = re.search(r'(?P<day>[0-3]?[0-9])[\-/\._]?(?P<month>[0-1]?[0-9])[\-/\._]?(?P<year>20[0-9]{2})', 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)
|
||||
folder = f"{match.group('year')}.{match.group('month')}.{match.group('day')}"
|
||||
else:
|
||||
match = re.search(r'(?P<day>[0-3]?[0-9])[\-/\._]?(?P<month>[0-1]?[0-9])[\-/\._]?(?P<year>20[0-9]{2})', filename)
|
||||
if match:
|
||||
folder = f"{match.group('year')}.{match.group('month')}.{match.group('day')}"
|
||||
else:
|
||||
folder = 'unknown-time'
|
||||
new_path = os.path.join(dirname, folder, filename)
|
||||
os.makedirs(os.path.dirname(new_path), exist_ok=True)
|
||||
if self.no_move == False:
|
||||
self._log.info(f"Moving file '{file}' to '{new_path}'...")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = image_classifier
|
||||
version = 0.0.4
|
||||
version = 0.0.5
|
||||
|
||||
[options]
|
||||
packages = image_classifier
|
||||
|
|
2
setup.py
2
setup.py
|
@ -9,7 +9,7 @@ if os.access(requirements_file, os.R_OK):
|
|||
setuptools.setup(
|
||||
scripts=['image_classifier/image_classifier.py'],
|
||||
author="Antonio J. Delgado",
|
||||
version='0.0.4',
|
||||
version='0.0.5',
|
||||
name='image_classifier',
|
||||
author_email="antoniodelgado@susurrando.com",
|
||||
url="",
|
||||
|
|
Loading…
Reference in a new issue