diff --git a/elodie/filesystem.py b/elodie/filesystem.py index 92d7807e..fd862d20 100644 --- a/elodie/filesystem.py +++ b/elodie/filesystem.py @@ -42,7 +42,7 @@ def __init__(self): # It captures some additional characters like the unicode checkmark \u2713. # See build failures in Python3 here. # https://travis-ci.org/jmathai/elodie/builds/483012902 - self.whitespace_regex = '[ \t\n\r\f\v]+' + self.whitespace_regex = '[ \t\n\r\f\v,/]+' # Instantiate a plugins object self.plugins = Plugins() @@ -168,7 +168,7 @@ def get_file_name(self, metadata): place_name, ) break - elif part in ('album', 'extension', 'title'): + elif part in ('album', 'extension', 'title', 'camera_make', 'camera_model'): if metadata[part]: this_value = re.sub(self.whitespace_regex, '-', metadata[part].strip()) break @@ -218,6 +218,8 @@ def get_file_name(self, metadata): name, ) + name = re.sub('[\?\*\0:|<>]', '_', name) + config = load_config() if('File' in config and 'capitalization' in config['File'] and config['File']['capitalization'] == 'upper'): @@ -588,7 +590,10 @@ def process_file(self, _file, destination, media, **kwargs): # Set the utime based on what the original file contained # before we made any changes. # Then set the utime on the destination file based on metadata. - os.utime(_file, (stat_info_original.st_atime, stat_info_original.st_mtime)) + try: + os.utime(_file, (stat_info_original.st_atime, stat_info_original.st_mtime)) + except OSError: + pass self.set_utime_from_metadata(metadata, dest_path) db = Db() diff --git a/elodie/media/text.py b/elodie/media/text.py index 4e3c6bbf..f81b6cbb 100644 --- a/elodie/media/text.py +++ b/elodie/media/text.py @@ -179,7 +179,10 @@ def write_metadata(self, **kwargs): # Create an _original copy just as we do with exiftool # This is to keep all file processing logic in line with exiftool - copy2(source, source + '_original') + try: + copy2(source, source + '_original') + except: + return if has_metadata: # Update the first line of this file in place