From fdb6821e6fbfcb0ad860223f9371e0a8dd3aab7c Mon Sep 17 00:00:00 2001 From: Alter-xyz <88554920+alterxyz@users.noreply.github.com> Date: Tue, 21 Mar 2023 22:21:31 -0400 Subject: [PATCH] New option for file name capitalization handling In this update, I have added a new option for file name capitalization handling, which allows users to convert specific parts of the file name to title case (first letter capitalized, other letters lowercase), while preserving the original case of the original_name. The previous code only supported two formats: all uppercase and all lowercase for whole file name. To implement this feature, I added a new conditional branch to check whether the 'capitalization' setting in the configuration file is set to 'title'. Users can specify the delimiter (in this case, ']') and how to handle different parts of the file name in the configuration file according to their needs. Possible future improvement: Support for extension capitalization. I hope this change will provide more flexibility and customization options. --- elodie/filesystem.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/elodie/filesystem.py b/elodie/filesystem.py index 92d7807e..08ec3ff6 100644 --- a/elodie/filesystem.py +++ b/elodie/filesystem.py @@ -222,6 +222,13 @@ def get_file_name(self, metadata): if('File' in config and 'capitalization' in config['File'] and config['File']['capitalization'] == 'upper'): return name.upper() + elif('File' in config and 'capitalization' in config['File'] and config['File']['capitalization'] == 'title'): + # Mine is: + # date=%d-%H%M%S + # name=%date [%city] %original_name.%extension + # Since strings before "]" are quite stable, it ensures that they can be split properly by "]" no matter what the original name is. + # "]" is replaceable. + return name.split(']', maxsplit=1)[0].title() + ']' + name.split(']', maxsplit=1)[1] else: return name.lower()