From cdfa408206343e161f532f0251940bb32cbc82b1 Mon Sep 17 00:00:00 2001 From: Cedric Leporcq Date: Tue, 19 Jul 2022 19:41:43 +0200 Subject: [PATCH] Fix get_date_from_string function --- ordigi/collection.py | 3 +++ ordigi/utils.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ordigi/collection.py b/ordigi/collection.py index f894641..77fd17b 100644 --- a/ordigi/collection.py +++ b/ordigi/collection.py @@ -143,6 +143,9 @@ class FPath: # Delete separator if re.search('^[-_ .]', part): part = part[1:] + if part != stem: + # We only want to match first result + break elif item == 'date': date = metadata['date_media'] # early morning photos can be grouped with previous day diff --git a/ordigi/utils.py b/ordigi/utils.py index 0a59f41..5a54913 100644 --- a/ordigi/utils.py +++ b/ordigi/utils.py @@ -69,7 +69,7 @@ def get_date_regex(user_regex=None): # regex to match date format type %Y%m%d, %y%m%d, %d%m%Y, # etc... 'a': re.compile( - r'.*[_-]?(?P\d{4})[_-]?(?P\d{2})[_-]?(?P\d{2})[_-]?(?P\d{2})[_-]?(?P\d{2})[_-]?(?P\d{2})' + r'[-_./](?P\d{4})[-_.]?(?P\d{2})[-_.]?(?P\d{2})[-_.]?(?P\d{2})[-_.]?(?P\d{2})[-_.]?(?P\d{2})' ), 'b': re.compile( r'[-_./](?P\d{4})[-_.]?(?P\d{2})[-_.]?(?P\d{2})[-_./]'