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
|
== 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:
|
if 'Exif.Photo.DateTimeOriginal' in self.metadata.exif_keys:
|
||||||
original_date = self.metadata['Exif.Photo.DateTimeOriginal'].value
|
original_date = self.metadata['Exif.Photo.DateTimeOriginal'].value
|
||||||
self._log.debug(f"File creation time: {original_date} (type: {type(original_date)})")
|
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)
|
folder = os.path.join(dirname, original_date.strftime('%Y.%m.%d'), filename)
|
||||||
if not new_path:
|
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)
|
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:
|
if match:
|
||||||
new_path = os.path.join(dirname, match.group('year'), match.group('month'), match.group('day'), filename)
|
folder = f"{match.group('year')}.{match.group('month')}.{match.group('day')}"
|
||||||
if not new_path:
|
else:
|
||||||
match = re.search(r'(?P<day>[0-3]?[0-9])[\-/\._]?(?P<month>[0-1]?[0-9])[\-/\._]?(?P<year>20[0-9]{2})', filename)
|
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:
|
if match:
|
||||||
new_path = os.path.join(dirname, match.group('year'), match.group('month'), match.group('day'), filename)
|
folder = f"{match.group('year')}.{match.group('month')}.{match.group('day')}"
|
||||||
if not new_path:
|
else:
|
||||||
new_path = os.path.join(dirname, 'unknown-time', filename)
|
folder = 'unknown-time'
|
||||||
|
new_path = os.path.join(dirname, folder, filename)
|
||||||
os.makedirs(os.path.dirname(new_path), exist_ok=True)
|
os.makedirs(os.path.dirname(new_path), exist_ok=True)
|
||||||
if self.no_move == False:
|
if self.no_move == False:
|
||||||
self._log.info(f"Moving file '{file}' to '{new_path}'...")
|
self._log.info(f"Moving file '{file}' to '{new_path}'...")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = image_classifier
|
name = image_classifier
|
||||||
version = 0.0.4
|
version = 0.0.5
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
packages = image_classifier
|
packages = image_classifier
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -9,7 +9,7 @@ if os.access(requirements_file, os.R_OK):
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
scripts=['image_classifier/image_classifier.py'],
|
scripts=['image_classifier/image_classifier.py'],
|
||||||
author="Antonio J. Delgado",
|
author="Antonio J. Delgado",
|
||||||
version='0.0.4',
|
version='0.0.5',
|
||||||
name='image_classifier',
|
name='image_classifier',
|
||||||
author_email="antoniodelgado@susurrando.com",
|
author_email="antoniodelgado@susurrando.com",
|
||||||
url="",
|
url="",
|
||||||
|
|
Loading…
Reference in a new issue