ramonsaraiva / pictory

Simple tool to organize pictures and videos in lickable directories
MIT License
36 stars 9 forks source link

Handling duplicates? #1

Closed weholt closed 6 years ago

weholt commented 6 years ago

Like this project, but it does not seem to handle duplicates.

ramonsaraiva commented 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?

weholt commented 6 years ago

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`
ramonsaraiva commented 6 years ago

Adding the Hacktoberfest label in case someone wants to work on it.

Abelarm commented 6 years ago

I'd like to work on this but i don't get exactly the problem neither the expected behaviour.

ramonsaraiva commented 6 years ago

@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.

Abelarm commented 6 years ago

This makes perfect sense to me :)

ramonsaraiva commented 6 years ago

Fixed on https://github.com/ramonsaraiva/pictory/pull/5