Closed weholt closed 6 years ago
Hello, unfortunately, not yet. I'll probably implement some duplicates/collision strategy for the files, like the possibility to either override them or duplicate them with a specific prefix/suffix.
What do you think?
I wrote a similar solution some years ago before using Lightroom for all my photo organization. The project is now retired, but it had a section looking like this (sorry for the bad formatting):
`default_duplicate_filename_format = '%(filename)s~%(counter)s%(file_extension)s'
def generate_valid_target(filename, duplicate_filename_format=default_duplicate_filename_format): """Generates a new filename if there is already an existing file with the same name.
:param filename: the target file we want to create
:returns: string
"""
counter = 1
while True:
if not os.path.exists(filename):
break
base_name, ext = os.path.splitext(filename)
filename = duplicate_filename_format % dict(filename=base_name, counter=counter, file_extension=ext)
counter += 1
return filename`
Adding the Hacktoberfest label in case someone wants to work on it.
I'd like to work on this but i don't get exactly the problem neither the expected behaviour.
@Abelarm right now the program halts if there are duplicates (files with the exact same name), we need to have different options to handle those..
I think the steps here would be to add a proper arguments parser, giving different options for file collisions, like:
No need for something complex, just a simple handling of duplicates.
This makes perfect sense to me :)
Like this project, but it does not seem to handle duplicates.