From aef467dfdd0d534ba990040e978bebb1ef73349f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 26 Jul 2026 15:00:46 -0700 Subject: [PATCH] Let read_mtime overwrite the name even if already formatted. --- photo_rename.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/photo_rename.py b/photo_rename.py index 2572559..4fbdaf4 100644 --- a/photo_rename.py +++ b/photo_rename.py @@ -21,8 +21,9 @@ def makename(file, read_exif=False, read_mtime=False, minus_duration=False): final_pattern = r'^(\d\d\d\d)-(\d\d)-(\d\d)_(\d\d)-(\d\d)-(\d\d)(?:x\d+)?$' # Already optimized filenames need not apply # This is also important when the filename and the exif disagree - if re.match(final_pattern, old) and not read_exif: - return file + if re.match(final_pattern, old) and not read_exif and not read_mtime: + # return file + pass # Microsoft ICE new = re.sub( @@ -156,9 +157,6 @@ def makename(file, read_exif=False, read_mtime=False, minus_duration=False): if new == old and read_exif and file.extension in {'jpg', 'jpeg', 'dng'}: new = makename_exif(file, old) - if new == old and re.match(final_pattern, new): - return file - if new == old and read_mtime: mtime = file.stat.st_mtime if minus_duration: @@ -166,6 +164,9 @@ def makename(file, read_exif=False, read_mtime=False, minus_duration=False): date = datetime.datetime.fromtimestamp(mtime) new = date.strftime('%Y-%m-%d_%H-%M-%S') + if new == old: + return file + new = file.parent.with_child(new).add_extension(file.extension) return new