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})[-_./]'